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 7 of 10 Topic 4044 of 4065
Post > Topic >>

Re: Euler problem #48

by Albert van der Horst <albert@[EMAIL PROTECTED] > May 8, 2008 at 05:00 PM

In article <88003316183559@[EMAIL PROTECTED]
>, Marcel Hendrix <mhx@[EMAIL PROTECTED]
>
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
>

Please don't publish spoilers without spoiler in the subject line.

Groetjes Albert

--
-- 
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- like all pyramid schemes -- ultimately falters.
albert@[EMAIL PROTECTED]
 &=n http://home.hccnet.nl/a.w.m.van.der.horst




 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:31:46 CDT 2008.