Skip to content

Commit a30538d

Browse files
author
André Bermudes Viana
authored
Added .c
1 parent d30a571 commit a30538d

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

CollatzConjecture/solution.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <stdlib.h>
2+
#include <stdio.h>
3+
4+
int main(){
5+
long int N = 26; //CALCULATING FOR N = 26
6+
long int biggestValue = 0;
7+
long int steps = 0;
8+
9+
while(N != 1){
10+
if(N%2 == 0){
11+
N = N/2;
12+
}else{
13+
N = N*3 + 1;
14+
}
15+
if(N>biggestValue){
16+
biggestValue = N;
17+
}
18+
steps++;
19+
}
20+
21+
printf("Number of Steps: %ld BiggestValue: %ld", steps, biggestValue);
22+
23+
}

0 commit comments

Comments
 (0)