Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //https://www.facebook.com/AminproPastebin
- //Direct recursion
- int f(int n){
- int result;
- if(n==0)
- result =0;
- else if(n%2 == 0){
- return = f(n/2);
- }
- else{
- return 1+ f(n-1);
- }
- //Mutual recursion
- int fOdd(int n){
- int result;
- result = (1+fEven(n-1));
- return result;
- }
- int fEven(int n){
- int result;
- if(n==)
- result = 0;
- else if ((n/2)%2==0)
- result = fOdd(n/2);
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement