Run ❯
Get your
own
website
×
Change Orientation
Change Theme, Dark/Light
Go to Spaces
Python
C
Java
prev2 = 0 prev1 = 1 print(prev2) print(prev1) for fibo in range(18): newFibo = prev1 + prev2 print(newFibo) prev2 = prev1 prev1 = newFibo #Python
#include
int main() { int prev2 = 0, prev1 = 1; int newFibo; printf("%d\n", prev2); printf("%d\n", prev1); for(int fibo = 0; fibo < 18; fibo++) { newFibo = prev1 + prev2; printf("%d\n", newFibo); prev2 = prev1; prev1 = newFibo; } return 0; } //C
public class Main { public static void main(String[] args) { int prev2 = 0; int prev1 = 1; System.out.println(prev2); System.out.println(prev1); for(int fibo = 0; fibo < 18; fibo++) { int newFibo = prev1 + prev2; System.out.println(newFibo); prev2 = prev1; prev1 = newFibo; } } } //Java
Python result:
C result:
Java result:
0
1
1
2
3
5
8
13
21
34
55
89
144
233
377
610
987
1597
2584
4181
0
1
1
2
3
5
8
13
21
34
55
89
144
233
377
610
987
1597
2584
4181
0
1
1
2
3
5
8
13
21
34
55
89
144
233
377
610
987
1597
2584
4181