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 /bigfactors2.c | |
parent | 125ec5bc3d8bfc224b7d32bcfbbc37b9fb5d441f (diff) | |
download | Project_Euler_Solutions-93ea7fe5957b62f18e8fbd17a21696bd7de6332d.tar.gz |
Organized everything, update README
Diffstat (limited to 'bigfactors2.c')
-rw-r--r-- | bigfactors2.c | 31 |
1 files changed, 0 insertions, 31 deletions
diff --git a/bigfactors2.c b/bigfactors2.c deleted file mode 100644 index 97ba17d..0000000 --- a/bigfactors2.c +++ /dev/null @@ -1,31 +0,0 @@ -#include <stdlib.h> -#include <stdio.h> -#include <math.h> - -int countFactors(int num){ - int factors = 0; - // Check only up until the square root of the number - int root = (int) ceil(sqrt(num)); - //printf("%d\n", root); - for(int i = 2; i < root; i++){ - if(num % i == 0) - factors+=2; - } - // Correction for perfect square - if(root * root == num) - factors -= 1; - return factors; -} - -int main(){ - int i = 1; - int k = 1; - int j = 0; - while(k < 500){ - j += i; - k = countFactors(j); - i += 1; - } - printf("%d has over 500 factors. Neat!\n", j); - return 0; -} |