-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsequences.java
More file actions
21 lines (20 loc) · 764 Bytes
/
sequences.java
File metadata and controls
21 lines (20 loc) · 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Online Java Compiler
// Use this editor to write, compile and run your Java code online
class HelloWorld {
public static void main(String[] args) {
System.out.println(String.format("%10s %20s %20s %20s %20s", "counter","square", "cube", "2exponent", "fibonacci"));
long number = -1;
long number2 = 1;
for(int counter = 1; counter <= 24; counter++) {
long fibonacciIs = number+number2;
number = number2;
number2 = fibonacciIs;
System.out.println(String.format("%10d %20d %20d %20d %20d",
counter,
(long)Math.pow(counter, 2),
(long)Math.pow(counter, 3),
(long)Math.pow(2, counter),
fibonacciIs));
}
}
}