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

LOGO-L> Number Sculpturing



Hello everybody,

We have enjoyed Word Sculpturing proposed by Yehuda, and what about 
number sculpturing? Let's begin with the following pyramid.

This pyramid uses the procedure of multiplication which I took from 
the "Informatics", the newspaper I've mentioned. This procedure  
imitates the process of large number multiplication we follow using 
pen and paper. As the integers are not large here, it isn't 
necessary to use the procedure, but without it the program 
wouldn't be interesting at all. :-)
I tried, but failed, to define the limits of it's implementation. The 
procedure allows to multiply the large integers, when the result 
is greater then the largest allowed integer, but in this process the 
intermediate sums shouldn't exceed it. I'm not sure, I'm making any 
sense. What I mean is --

let's multiply 234 and 567. 
The result may be obtained as 
234  * 7 + (234 * 6) * 10 + (234 * 5 ) * 100
So, every time we have to multiply 234 (the first integer) and 
1-digital integer and then move the result left and add it to the 
previous intermediate sum. If we'll store the result as a word (why 
not, if it's useful? :-) ) then it may exceed the largest allowed 
integer. But intermediate results shouldn't exceed this largest 
integer. And I don't know how this problem may be solved before hand, 
that is, before we begin  multiplication  and get something like 
"remainder doesn't like 999 999 999 999 999 as an input".

And now here is a Number Pyramid:

to number.pyramid.ini
ct
number.pyramid 1 1
end

to number.pyramid  :l :k
if :l>9 [stop]
(pr :k "*8+ :l "= proc.mult :k 8 :l ")
number.pyramid  :l+1 10*:k+:l+1
end

to proc.mult :x :y :s :res
ifelse not :y=0 [make "s :s+:x*(remainder :y 10)
                 op proc.mult :x int :y/10 int :s/10 ~
                            word remainder :s 10 :res]~
                [if not :s=0 [make "res word :s :res] op :res ]
end
------------------------------------
------------------------------------
Hope, you'll like it.

Regards, Olga.

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