Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int coll (int a,int c)
- {
- //if a is odd number
- if(a%2==1 && a!=1)
- {
- coll ((3*a)+1, c++);
- }
- //If a is even number
- else if(a%2==0 && a!=1)
- {
- coll (a/2, c++);
- }
- //Base case returns the value of c
- else
- return c;
- }
Add Comment
Please, Sign In to add comment