[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: LOGO-L> Xmas - The Gift of Life - Conway's +...



At 17:26 24-12-98 -0500, you wrote:
[snip]
> Since my first love was Mathematics, I knew
>the answer was 52! (52 factorial). Having had brief affairs with number
>theory, cryptoanalysis etc, I've known since I was a teen-ager that the
>answer was about 68 digits long. 35 Years in the computer industry, while
>it feds the kids, etc. didn't help, and indeed frustrated me more. Almost
>every computer language out there cuts out at 10-12 digits and goes to
>E-notation. But I wanted to know exactly how many hands were possible!  
> Then I discovered UBASIC, a very small (120K executable!), program that
>allowed 2400 digit accuracy! It took a 10 line program, to get the answer 

In fact each Logo is capable to make such computation like factorial of
given number. You should have a little more patience then 2651
milliseconds, but our Logo will discover (with it's well known turtle
speed) 80658175170943878571660636856403766975289505440883277824000000000000
as a 52! and even
1029901674514562762384858386476504428305377245499907218232549177688787173247
5287174542709871683888003235965704141638377695179741979175588724736000000000
000000000000000 as 104!

Here is a small program which did it:

to b.sum :a :b
output b.add :a :b 0
end

to b.add :a :b :c
if and emptyp :a emptyp :b [ifelse :c=1 [output "1][output " ]]
if emptyp :a [output b.add :b :c "0]
if emptyp :b [output b.add :a :c "0]
ifelse(sum last :a last :b :c)>9~
  [output word b.add bl :a bl :b "1 remainder (sum last :a last :b :c) 10]~
  [output word b.add bl :a bl :b "0 remainder (sum last :a last :b :c) 10]
end

to b.mult :a :b
if emptyp bl :b [output b.mult1cyf :a last :b]
output b.sum word b.mult :a bl :b "0 b.mult1cyf :a last :b
end

to b.mult1cyf :number :digit
if :digit=0 [output "0]
if :digit=1 [output :number]
output b.sum :number b.mult1cyf :number :digit-1
end

to factorial :k
if :k=0 [output 1]
if :k=1 [output 1]
output b.mult :k factorial :k-1
end

It took about 2 minutes to calculate 52! and much longer to get 104! and I
agree that is not a very good result in a day of "information at Your
fingertips", but as long as there are holidays I can wait for result few
minutes longer.
Someone may say, it is nothing extraordinary in Logo to do this
computation. It could be done in Basic, Pascal (and C of course) as well
and even much faster. In my opinion a point is when we may show possibility
of solving problem with our programming tool "aimed at children and other
beginning programmers". 

Best regards and a Happy New Year

Andrzej B.
Lodz, Poland


---------------------------------------------------------------
Please post messages to the Logo forum to logo-l@gsn.org.  Mail
questions about the list administration to logofdn@gsn.org.  To
unsubscribe send    unsubscribe logo-l    to majordomo@gsn.org.



Global SchoolNet Foundation - Linking Kids Around the World!
Copyright GSN - All Rights Reserved - Comments & Questions
Visit GSN's Global Schoolhouse for more exciting learning resources!
Search our Site - Home