#include
#include
int main()
{
int n;
printf("please enter an integer:");
scanf("%d",&n);
printf("\n");
while(n>=2)//若n<=1跳出loop
{
int a;
a=(n)%2;//a是n除2的餘數
if(a==0)//a=0表n為偶數
{
n=0.5n;
printf("%d ",n);
}
if(a==1)//a=1表n為奇數
{
n=3n+1;
printf("%d ",n);
}
}
printf("\n");
return 0;
}
-
Notifications
You must be signed in to change notification settings - Fork 0
yantinger/lab1
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published