-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
35 lines (27 loc) · 950 Bytes
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <stdio.h>
#include <math.h>
int main(int argc, char const *argv[])
{
unsigned long long numberBegin = 1;
int one = 1;
unsigned long long numberCurrent = numberBegin;
unsigned long long numberEnd = pow(2, 64) - 1;
while (numberBegin != numberEnd) // Runs until the number where the counting starts hits the defined limit
{
printf("%20llu", numberCurrent); //Output of Current Number
printf("%50llu\n", numberBegin);
if (numberCurrent % 2 != 0) // if number is odd: multiple *3 and add 1, if not divide by 2
{
numberCurrent = 3 * numberCurrent + 1;
}else{
numberCurrent = numberCurrent / 2;
}
if (one == numberCurrent)
{
printf("%2llu\n", numberCurrent); //Output of Current Number
numberBegin = numberBegin + 1;
numberCurrent = numberBegin;
}
}
return 0;
}