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

#1 2008-10-09 15:28:43

BBK
Scratcher
Registered: 2008-10-09
Posts: 4

Maths Problem

I need to enter two numbers using the slider bars

Number 1=x
Number 2=x
Answer=x

Then i need it to take number one and make number two the 'to the power of'

For instance

e.g 1
Number 1=5
Number 2=4

So that will become 5^4 and the calculation is 5*5*5*5

e.g 2
Number 1=9
Number 2=5

So that will become 9^5 and the calculation is 9*9*9*9*9

Then display the answer

I Can do the sliders and all that for basics maths, i'm having trouble to get it to work this out as i don't know how to tell it to use Number 1 (slider 2) and multiply itself by the value of slider 2

Hope thats makes sense

Any help would be greatly appreciated

Offline

 

#2 2008-10-09 16:10:14

Mayhem
Scratcher
Registered: 2007-05-26
Posts: 1000+

Re: Maths Problem

3 variables required:

Number
Power
Result

Then, after Number and Power are entered:

Set (Result) = 1
Repeat (Power)
  Set Result=(Result)*(Number)

So, if you entered 5 and 4, as in your example

1st repeat:  Result = 1x5 = 5
2nd Repeat: Result = 5x5 = 25
3rd Repeat: Result =25x5 = 525
4th Repeat: Result = 525 x 5 = 2625

Doesn't work if the power is set to less than one, though.  If you need these, you'd need some additional tweaking.


Web-spinning Spider:  http://scratch.mit.edu/projects/Mayhem/18456
3D Dungeon Adventure:  http://scratch.mit.edu/projects/Mayhem/23570
Starfighter X: http://scratch.mit.edu/projects/Mayhem/21825
Wandering Knight: http://scratch.mit.edu/projects/Mayhem/28484

Offline

 

#3 2008-10-09 16:13:33

Mayhem
Scratcher
Registered: 2007-05-26
Posts: 1000+

Re: Maths Problem

Here:  http://scratch.mit.edu/projects/Mayhem/287259


Web-spinning Spider:  http://scratch.mit.edu/projects/Mayhem/18456
3D Dungeon Adventure:  http://scratch.mit.edu/projects/Mayhem/23570
Starfighter X: http://scratch.mit.edu/projects/Mayhem/21825
Wandering Knight: http://scratch.mit.edu/projects/Mayhem/28484

Offline

 

#4 2008-10-09 16:25:23

BBK
Scratcher
Registered: 2008-10-09
Posts: 4

Re: Maths Problem

Thanks a million

Greatly appreciated

Offline

 

Board footer