diff --git a/C/10. Summation_of_primes/Kavya-Shekar.c b/C/10. Summation_of_primes/Kavya-Shekar.c index 93dabd8..1d8668b 100644 --- a/C/10. Summation_of_primes/Kavya-Shekar.c +++ b/C/10. Summation_of_primes/Kavya-Shekar.c @@ -1,31 +1,31 @@ -// Problem 10 : Summation of primes -// The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. -// Find the sum of all the primes below two million. - -#include -#include - -int prime(long n); -// return 1 if n is prime, else returns 0 - -int main() -{ - long n = 2000000; - long sum = 2; - for(long i = 3; i +#include + +int prime(long n); +// return 1 if n is prime, else returns 0 + +int main() +{ + long n = 2000000; + long sum = 2; + for(long i = 3; i + +int main() +{ + int a[200],n,counter,temp; + a[0]=1; + counter=0; + n = 100; + for(; n>=2; n--) + { + temp=0; + for(int i=0; i<=counter; i++) + { + temp=(a[i]*n)+temp; + a[i]=temp%10; + temp=temp/10; + } + while(temp>0) + { + a[++counter]=temp%10; + temp=temp/10; + } + } + int sum = 0; + for(int i=0;i<=counter;i++) + sum+=a[i]; + + printf("Sum of digits in 100 factorial : %d",sum); + +} \ No newline at end of file diff --git a/README.md b/README.md index 75ce920..438eaec 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ Happy Contributing! 😃 | 17 | [Number letter counts](https://projecteuler.net/problem=17) | | | | :white_check_mark: | | | | | | | | | | 18 | [Maximum path sum I](https://projecteuler.net/problem=18) | | | | :white_check_mark: | | | | | | | | | | 19 | [Counting Sundays](https://projecteuler.net/problem=19) | | | | | | | | | | | | | -| 20 | [Factorial digit sum](https://projecteuler.net/problem=20) | | :white_check_mark: | | :white_check_mark: | :white_check_mark: | | | | | | | | +| 20 | [Factorial digit sum](https://projecteuler.net/problem=20) | | :white_check_mark: | | :white_check_mark: | :white_check_mark: | | :white_check_mark: | | | | | | | 21 | [Amicable numbers](https://projecteuler.net/problem=21) | | | | | | | | | | | | | | 22 | [Names scores](https://projecteuler.net/problem=22) | | | | :white_check_mark: | | | | | | | | | | 23 | [Non-abundant sums](https://projecteuler.net/problem=23) | | | | | | | | | | | | | @@ -81,7 +81,6 @@ Happy Contributing! 😃 | 49 | [Prime permutations](https://projecteuler.net/problem=49) | | | | :white_check_mark: | | | | | | | | | | 50 | [Consecutive prime sum](https://projecteuler.net/problem=50) | | | | :white_check_mark: | | | :white_check_mark: | | :white_check_mark: | | | | - ## Thanks