- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask_153.java
More file actions
Latest commit
19 lines (16 loc) · 467 Bytes
/
Copy pathTask_153.java
File metadata and controls
19 lines (16 loc) · 467 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
importjava.util.Scanner;
publicclassTask_153 {
publicstaticvoidmain(String[] args) {
Scanners = newScanner(System.in);
intn = s.nextInt();
System.out.println(fibo(n));
}
privatestaticlongfibo(intn) {
if (n < 3) return1;
returnfibo(n - 2, 1, 1);
}
privatestaticlongfibo(intcount, longa, longb) {
if (count == 1) returna + b;
returnfibo(count - 1, b, a + b);
}
}