Project Euler #254: Sums of Digit Factorials

  • + 4 comments
    g(1)= 1, sf( 1) = s(   1!) = s(  1) =     1 = 1
    g(2)= 2, sf( 2) = s(   2!) = s(  2) =     2 = 2
    g(3)= 5, sf( 5) = s(   5!) = s(120) = 1+2+0 = 3
    g(4)=15, sf(15) = s(1!+5!) = s(121) = 1+2+1 = 4
    There is no number smaller than 15 which yeild 4.
    

    Let's take 1 query at a time and ignore the modulo.
    n=4 would mean :

    sg(1)+sg(2)+sg(3)+sg(4)
     s(1)+ s(2)+ s(5)+s(15)
       1 +   2 +   5 + 1+5