On May 7, 3:55 pm, m...@[EMAIL PROTECTED]
(Marcel Hendrix) wrote:
> INCLUDE ../bignum/factor.frt
>
> (*
> The series, 1^1 + 2^2 + 3^3 + ... + 10^10 = 10405071317.
>
> Find the last ten digits of the series, 1^1 + 2^2 + 3^3 + ... +
1000^1000.
> *)
>
> : INIT ( -- ) S" 10000000000" s2 >GIANT S" 0" s3 >GIANT ;
> : TERM ( n -- ) DUP 0 <# #S #> s1 >GIANT s1 SWAP s2 GS^MOD s3 s1
GG+ ;
> : 1000T ( -- g ) INIT #1001 1 DO I TERM LOOP s3 s2 GGMOD s3 .GIANT ;
>
> : Euler48 ( -- )
> CR ." The last ten digits of the series 1^1 + 2^2 + 3^3 + ... +
1000^1000 are " 1000T ;
>
> : .ABOUT CR ." Euler48 -- Find the last ten digits of the series, "
> CR ." 1^1 + 2^2 + 3^3 + ... + 1000^1000." ;
>
> .ABOUT
>
> \ FORTH> euler48
> \ The last ten digits of the series 1^1 + 2^2 + 3^3 + ... + 1000^1000
are xxxxxxxxxx
> \ 0.011 seconds elapsed. ok
In PARI/gp. 0 ms. It yields more than 10 digits.
sum(i=1,1000,lift( Mod(i,10^10)^i ) )


|