diff options
author | mjf <mjf@localhost.localdomain> | 2020-02-04 12:11:30 -0500 |
---|---|---|
committer | mjf <mjf@localhost.localdomain> | 2020-02-04 12:11:30 -0500 |
commit | 6aa02212cd6dfbb492fa1f70b60a4fe3d48892e5 (patch) | |
tree | 1b655714c9709ee8fce333fcb6a6be3f5533b2d3 /largestprime.c | |
parent | 8e431d287c0e89041506da4c4da57e3e3d657d72 (diff) | |
download | Project_Euler_Solutions-6aa02212cd6dfbb492fa1f70b60a4fe3d48892e5.tar.gz |
cleanup and added more c examples:
Diffstat (limited to 'largestprime.c')
-rw-r--r-- | largestprime.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/largestprime.c b/largestprime.c new file mode 100644 index 0000000..bf98414 --- /dev/null +++ b/largestprime.c @@ -0,0 +1,21 @@ +#include <stdio.h> +#include <stdlib.h> + +long lpf(long num){ + long factor = 2; + while(num > factor){ + if(num % factor == 0){ + num = num / factor; + factor = 2; + } + else{ + factor ++; + } + } + return factor; +} + +int main(){ + printf("%d\n", lpf(600851475143)); + return 0; +} |