This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-03-01 12:51:39

technoboy10
Scratcher
Registered: 2007-08-25
Posts: 1000+

Factorial Blues

No, I'm not going to sing. So there. Anyway, I am making a factorial program to help me w/ math; and I am noticing the lack of factorial blocks. And I would like to be able to post the project. Anybody know how to do this?

P.S. If possible, it needs to be able to compute multi-tier factorials, i.e. 5!!!.\


Thanks!


So long, 1.4.
http://goo.gl/3JEV9

Offline

 

#2 2012-03-01 13:13:08

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Factorial Blues

You can hack Scratch to do what you need very easily with some Squeak code. I would be surprised if the block library didn't have that code yet, so check there. However, this means you cannot upload the project online.

So if you want something to work for everyone, you can use a simple recurring script, as the example below shows for calculating 5 factorial:

set [input v] to (5)
set [iteration v] to (1)
set [value v] to (1)
repeat ((input) - (1))
  change [value v] by ((iteration) * (value))
  change [iteration v] by (1)
end
This yields the answer 120, which is correct.

Last edited by LS97 (2012-03-01 13:28:45)

Offline

 

#3 2012-03-01 13:32:11

technoboy10
Scratcher
Registered: 2007-08-25
Posts: 1000+

Re: Factorial Blues

Thanks, LS97! I originally used a custom block, but I wanted the upload ability.


So long, 1.4.
http://goo.gl/3JEV9

Offline

 

#4 2012-03-01 13:38:29

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Factorial Blues

technoboy10 wrote:

Thanks, LS97! I originally used a custom block, but I wanted the upload ability.

I see. Well, you're most welcome  wink

Offline

 

#5 2012-03-01 14:20:33

cheddargirl
Scratch Team
Registered: 2008-09-15
Posts: 1000+

Re: Factorial Blues

Closed by request.


http://i.imgur.com/8QRYx.png
Everything is better when you add a little cheddar, because when you have cheese your life is at ease  smile

Offline

 

Board footer