Last active
September 17, 2019 03:14
-
-
Save Ts-Pytham/51c5da8b60ef5660fc9cbebc3c279e5f to your computer and use it in GitHub Desktop.
Sucesión de Fibonacci en C++/Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstdint> | |
#define bucle(a, b) for(a = 0; a < b; ++a) | |
#define input(a) std::cin>>a; | |
int main(){ | |
uint64_t aux, prim = 1, ant = 0, r=0, b, d = 0; | |
std::string c = "*"; | |
std::cout<<"Ingrese el rango para terminar la sucesion de Fibonacci:"<<std::endl; | |
input(r); | |
bucle(b, r){ | |
if (d >= 1 && d <= 4) | |
c +="*"; | |
else{ | |
std::cout<<"\n"; | |
c = "*"; | |
d = 0; | |
} | |
std::cout<<c<<"\t"<<prim<<std::endl; | |
aux = prim; | |
prim += ant; | |
ant = aux; | |
++d; | |
} | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
prim = 1 | |
ant = 0 | |
c = "*" | |
d = 0 | |
r = int(input("Ingrese el rango a terminar para la sucesión de Fibonacci.")) | |
for i in range(0,r): | |
if d >=1 and d<=4: | |
c+="*" | |
else: | |
d = 0 | |
print("\n") | |
c = "*" | |
print(f"{c}\t{prim}") | |
aux = prim | |
prim+=ant | |
ant = aux | |
d+=1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment