Skip to content

Instantly share code, notes, and snippets.

@jorgejr568
Last active October 29, 2016 20:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jorgejr568/042d30c1026d2379cd2c9731c0db7ae8 to your computer and use it in GitHub Desktop.
Save jorgejr568/042d30c1026d2379cd2c9731c0db7ae8 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <locale.h>
using namespace std;
int main(){
int qtd,n1=1,n2=1,i=0,tmp;
setlocale(LC_ALL,"Portuguese");
cout << "Digite a quantidade da sequência: ";
cin >> qtd;
if(qtd>0){
cout << 1;
if(qtd>1){
cout << ",1";
}
qtd-=2;
while(qtd>i){
cout << "," << (n2+n1);
tmp=n1;
n1=(n2+n1);
n2=tmp;
i++;
}
}
else{
cout << "Quantidade inválida";
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment