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