0
Why this problem print 95?
public class First { public static int CBSE(int x){ if(x < 100) x=CBSE(x + 10); return (x-1); } public static void main (String[] args){ System.out.print(First.CBSE(60)); } }
2 odpowiedzi
+ 3
The method is called recursively until x has a value greater or equal 100. This takes 5 iterations (60>70>80>90>100). After this is reached, for each iteration there is subtracted 1. 100-1-1-1-1-1 = 95