







Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!








1
2
3
4
7
8
9
10
13
14
15
16
public long factorialHelper (int n, int result){ if (n == 1) return result; else return factorialHelper(n-1,nresult); }*
public long factorial(int n){ return factorialHelper(n,1); }
19
20
21
22
25
Base Conversion (Tail Recursive)
public String baseConversionTRHelper(int n, String result) { int base = 2; // binary if( n < base ) { return Integer. toString (n)+result; } else { int quotient = n / base; String remainder = Integer. toString (n % base); return baseConversionTRHelper(quotient,remainder+result); } }
public String baseConversionTR(int n) { return baseConversionTRHelper(n,""); }