Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class name {
- public void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int n =sc.nextInt();
- fib(1, 1, 0, n);
- }
- public static void fib(int a, int b, int i, int n){
- if (a == 1 && b == 1){
- System.out.print("1 1 ");
- fib(b, a + b, i + 2,n);
- }else{
- System.out.print(b);
- if (i + 1 < n)
- fib(b, a + b, i + 1, n);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement