diff options
author | mjfernez <mjfernez@gmail.com> | 2020-02-09 15:16:26 -0500 |
---|---|---|
committer | mjfernez <mjfernez@gmail.com> | 2020-02-09 15:16:26 -0500 |
commit | 93ea7fe5957b62f18e8fbd17a21696bd7de6332d (patch) | |
tree | d90aed60d687bcf195f1150777f37cbe8a149814 /03-Largest-Prime-Factor/largestprime.c | |
parent | 125ec5bc3d8bfc224b7d32bcfbbc37b9fb5d441f (diff) | |
download | Project_Euler_Solutions-93ea7fe5957b62f18e8fbd17a21696bd7de6332d.tar.gz |
Organized everything, update README
Diffstat (limited to '03-Largest-Prime-Factor/largestprime.c')
-rw-r--r-- | 03-Largest-Prime-Factor/largestprime.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/03-Largest-Prime-Factor/largestprime.c b/03-Largest-Prime-Factor/largestprime.c new file mode 100644 index 0000000..bf98414 --- /dev/null +++ b/03-Largest-Prime-Factor/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; +} |