12th Aug 2017, 7:48 AM
Pavi Mohan
Pavi Mohan - avatar
2 odpowiedzi
+ 9
class sam{ public static int f(int x){ if(x==0) return 2; else return 1+ f(x-1); } public static void main(String args[]){ System.out.println(f(3)); } } f(3) = 1 + f(2) = 1 + 1 + f(1) = 1 + 1 + 1 + f(0) = 1 + 1 + 1 + 2 = 5
12th Aug 2017, 7:59 AM
Hatsy Rei
Hatsy Rei - avatar
0
tq frds
12th Aug 2017, 9:36 AM
Pavi Mohan
Pavi Mohan - avatar