Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static int f(int n) {
- int prod = 1;
- while (n > 1) {
- prod = prod * n;
- n = n - 2;
- }
- return prod;
- }
- public static int fRec(int n){
- return recHelp(n, 1);
- }
- public static int recHelp(int n,int prod){
- if (n > 1) {
- prod = prod * n;
- n = n - 2;
- return recHelp(n, prod);
- }
- return prod;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement