Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package dadaproject.company;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- int i1 = 0, i2 = 1, sum, num;
- System.out.println("Enter the number of terms:");
- Scanner number = new Scanner(System.in);
- num = number.nextInt();
- for (int i = 1; i <= num; i++) {
- sum = i1 + i2;
- System.out.print(i1+" ");
- i1 = i2;
- i2 = sum;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement