Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <cstdlib>
- #include <iostream>
- using namespace std;
- int seque (int a);
- main()
- {
- system("color B1");
- int num=0;
- cout<<"Inserisci un numero: ";
- cin>>num;
- num=seque (num);
- system("pause");
- return 0;
- }
- int seque(int a)
- {
- int b;
- if(a%2!=0)
- {
- a=a*3+1;
- for( b=0;a==1;b++)
- {
- a=a/2;
- cout<<" "<<a<<endl;
- cout<<"Iterazione numero: "<<b;
- }
- }
- else
- {
- for( b=0;a==1;b++)
- {
- a=a/2;
- cout<<" "<<a<<endl;
- cout<<"Iterazione numero: "<<b;
- }
- }
- cout<<"Numero di iterazini: "<<b<<endl;
- return b;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement