Created
October 17, 2020 03:30
-
-
Save alsamitech/8b2e568b0aa8310d25b5a37d00b18244 to your computer and use it in GitHub Desktop.
Collatz Conjecture Calculator: Implementation in C
This file contains hidden or 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 <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