Posts

Showing posts with the label problem 20

Factorial digit sum | Project Euler | Problem #20

URL to the problem page:  https://projecteuler.net/problem=20 n! means n × (n − 1) × ... × 3 × 2 × 1 For example, 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800, and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27. Find the sum of the digits in the number 100! #include   <iostream> using   namespace   std ; int   main () {      const   int  k =  158 ;      int   number [k] = {  0  },  result [ 3 ][k] = {  0  }, carry, carry2, carry3, sum =  0 , i, a,  multiply [ 3 ] = {  0 ,  0 ,  2  };      number [k -  1 ] =  1 ;      for  (a =  1 ; a <  100 ; a++) {         carry = carry2 = carry3...
My photo
Ercan Tomac
instagram.com/ercantomac