Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class sample{
- public static void main(String[] args) {
- int f=0, s=1, t, temp;
- Scanner scan_end = new Scanner(System.in);
- System.out.print("Enter the number of terms : ");
- String str_end = scan_end.nextLine();
- int end = Integer.parseInt(str_end);
- System.out.println(f);
- System.out.println(s);
- for (int i=0;i<end-2;i++){
- t = f + s;
- System.out.println(t);
- f = s;
- s = t;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment