Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main(){
- int nx,VA;
- cout<<"Este programa imprimira una secuencia de numeros iterativamente "<<endl;
- cout<<"Ingresar numero"<<endl;
- cin>>nx;
- if(nx<=0){
- cout<<"Chupa el pico ctm, pone otro numero: ";
- cin>>nx;
- }
- while(nx>0){
- cout<<nx<<" / ";
- if(nx%2==0){
- nx=nx/2;
- cout<<nx<<" / ";
- }
- else if(nx==1){
- break;
- }
- else if(nx%2==1){
- nx=(3*nx)+1;
- cout<<nx<<" / ";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement