Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Forth > Re: Euler probl...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 8 of 10 Topic 4044 of 4065
Post > Topic >>

Re: Euler problem #48

by William James <w_a_x_man@[EMAIL PROTECTED] > May 9, 2008 at 08:44 AM

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 ) )




 10 Posts in Topic:
Euler problem #48
mhx@[EMAIL PROTECTED] (M  2008-05-07 22:55:35 
Re: Euler problem #48
Bernd Paysan <bernd.pa  2008-05-08 11:22:15 
Re: Euler problem #48
anton@[EMAIL PROTECTED]   2008-05-08 10:28:32 
Re: Euler problem #48
Thomas Pornin <pornin@  2008-05-08 14:18:40 
Re: Euler problem #48
Bernd Paysan <bernd.pa  2008-05-08 16:33:41 
Re: Euler problem #48
Albert van der Horst <  2008-05-09 02:08:35 
Re: Euler problem #48
Albert van der Horst <  2008-05-08 17:00:16 
Re: Euler problem #48
William James <w_a_x_m  2008-05-09 08:44:42 
[SPOILER] Re: Euler problem #48
mhx@[EMAIL PROTECTED] (M  2008-05-09 19:13:05 
Re: [SPOILER] Re: Euler problem #48
Albert van der Horst <  2008-05-09 22:07:32 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat May 17 3:45:04 CDT 2008.