repl.it
@SharkFin/

Fibonacci

C++11

No description

fork
loading
Files
  • main.cpp
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <chrono>

int main() {
	int l;
	long long int x1 = 0, x2 = 1, x3 = 0;
  std::cout << "How many times to loop? ";
	std::cin >> l;

	std::cout << "Looping " << l << " times" << std::endl;
	for(int i=0;i<l;i++) {
		std::cout << x1 << std::endl;
		x3 = x1 + x2;
		x2 = x1;
		x1 = x3;
	}
	std::cout << "Loop completed" << std::endl;

	return 0;
}
?