Advertisement
GameNCode

ReverseNums Recursion2

Oct 25th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. public class ReverseNum {
  2. public static int nlen(int n)
  3. {
  4. if (n<10)
  5. return 1;
  6. return 1+nlen(n/10);
  7. }
  8.  
  9. public static int ex4(int n)
  10. {
  11. if (n<10)
  12. return n;
  13. return (n%10*(int)Math.pow(10,nlen(n)-1))+ex4(n/10);
  14. }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement