CPP
cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*
Hacer un programa que realice la serie de Fibonacci (1, 1, 2, 3, 5, 8, 13… n.
Make a program that calculates the Fibonacci sequence.
*/
#include<iostream>
#include<stdlib.h>
using namespace std;
int main(){
unsigned long int n, z = 0, x = 1, y = 0;
cout<<"Enter the number of n: ";cin>>n;//Ingrese el numero de n.
for(int i=0;i<=n;i++){
cout<<z<<", ";
z = x+y;//
x=y;
y=z;
}
cout<<"..."<<endl;
system("pause");
return 0;
}
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run