DS-Recursion

This commit is contained in:
e2hang
2025-07-17 15:30:55 +08:00
parent dd0d210e84
commit 2ed81d2e89
10 changed files with 56 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
#include <iostream>
using namespace std;
int cf(int n){
if(n%2 == 1)
return cf(3*n + 1);
if(n%2 == 0)
return n / 2;
}
int main(){
cout << cf(5) << " "<< cf(6) << " " << cf(7) << endl;
return 0;
}