Skip to content

Commit b85ec96

Browse files
committed
Add fermat numbers in C
Update TrackingProgress.md
1 parent c4ab54a commit b85ec96

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

Fermat Numbers/fermat_numbers.c

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
Compile Instructions:
3+
In order to compile this code use must link the math library.
4+
5+
Example: gcc fermat_numbers.c -o exec -lm
6+
*/
7+
#include <stdio.h>
8+
#include <math.h>
9+
10+
int main()
11+
{
12+
unsigned long long base = 2, power, innerPower, endResult;
13+
printf("Fermat Numbers Sequence: F_n = 2 ^ (2^n) + 1\n");
14+
printf("Enter the power raised (n): ");
15+
scanf("%llu",&power);
16+
17+
innerPower = pow(2,power); // Calculate 2 ^ n
18+
19+
endResult = pow(2,innerPower) + 1; // Calculate 2 ^ result + 1
20+
21+
printf("Result: 2 ^ (2^%llu) + 1 = %llu\n", power, endResult);
22+
23+
return 0;
24+
}

TrackingProgress.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
<tr>
117117
<td align=center><p> &#9203;</p></td>
118118
<td><a href="./Fermat Numbers">Fermat numbers</a></td>
119-
<td>Python, C++, Java, C#</td>
119+
<td>Python, C++, Java, C#, C</td>
120120
</tr>
121121
<tr>
122122
<td align=center><p> &#9989;</p></td>

0 commit comments

Comments
 (0)