Skip to content

Instantly share code, notes, and snippets.

@alsamitech
Created October 17, 2020 03:30
Show Gist options
  • Select an option

  • Save alsamitech/8b2e568b0aa8310d25b5a37d00b18244 to your computer and use it in GitHub Desktop.

Select an option

Save alsamitech/8b2e568b0aa8310d25b5a37d00b18244 to your computer and use it in GitHub Desktop.
Collatz Conjecture Calculator: Implementation in C
#include <stdio.h>
#include <stdlib.h>
int main() {
printf("Enter any number of type \"int\" : ");
int YinNum1;
scanf("%d yin",&YinNum1);
for(;;) {
if(YinNum1 % 2 == 0){
YinNum1=YinNum1/2;
printf("Number is even\n");
}else{
YinNum1=(YinNum1*3)+1;
printf("NUBER IS ODD\n");
}
printf("Your Number of type \"int\" is: %d\n", YinNum1);
if(YinNum1==1){
printf("Number Reached 1, Operation Sucsessful!\n");
break;
} else if(YinNum1==0){
printf("Number Is Equal to 0, Please Try again or debug the program (something went wrong)\n");
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment