0

How This made 7 can i get help is This add 2 in any circle or just one and then condition till the base case done

public class Program { private static int f(int i){ if (i<=0){ return 1; } else { return (2+f(i-1));i= 1 (return 1) } } public static void main(String[] args) { System.out.println(f(3)); } }

13th Nov 2020, 5:23 AM
Asma Omer
Asma Omer - avatar
3 Réponses
+ 2
Remove the "i = 1 (return 1)". It seems that it's not needed there.
13th Nov 2020, 5:38 AM
Leon lit
Leon lit - avatar
+ 2
Ya the calculation will be as what you stated there
13th Nov 2020, 10:50 AM
Leon lit
Leon lit - avatar
0
Yes by wrong🤗 Is This in memory calc 2+2+2+1 ?
13th Nov 2020, 5:43 AM
Asma Omer
Asma Omer - avatar