-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfor33.java
More file actions
30 lines (27 loc) · 639 Bytes
/
for33.java
File metadata and controls
30 lines (27 loc) · 639 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package fori;
import java.util.Scanner;
public class for33 {
public static void main(String[] args) {
int n;
int a1 = 1;
int a2 = 1;
int a;
Scanner scanner=new Scanner(System.in);
System.out.print(" n: ");
n = scanner.nextInt();
System.out.print("");
System.out.print(a1);
System.out.print(" ");
System.out.print(a2);
System.out.print(" ");
for (int i = 3; i <= n; ++i)
{
a = a1 + a2;
a1 = a2;
a2 = a;
System.out.print(a);
System.out.print(" ");
}
System.out.print("\n");
}
}