LOGO-L> Number Sculpturing
Author Message 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.

---------------------------------------------------------------

Sun, 12 Dec 1999 03:00:00 GMT  LOGO-L> Number Sculpturing

Quote:

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

Olga,

Beautiful AND interesting.

If you want your number pyramid to look more like a number pyramid,
you might try the following (there's really no need for PROC.MULT here):

=======================================
to main ; Pyramid by Olga T.
ts ct
pyramid 1 1
end

to pyramid  :l :k
if :l>9[stop]
pr(word form :k 9 0 "*8+ :l "= :k*8+:l)
pyramid :l+1 10*:k+:l+1
end
=======================================

Enjoy,

[[Yehuda]]

---------------------------------------------------------------

Sun, 12 Dec 1999 03:00:00 GMT

 Page 1 of 1 [ 2 post ]

Relevant Pages