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

#1 2010-11-09 18:36:07

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

How do I Add Consequetive numbers In Scratch

[Edit: Moderator Intrusiveness: I just added the quoted the original post here and removed the original one. Hope y'all don't mind, just thought it's simpler this way. --fullmoon]

ansman wrote:

Hi Guys,

I need your urgent response to do . How do I add the first 100 positive integer numbers in Scratch.

Hope to hear back from you soon.

Cheers

...What are you adding them to? A list? A variable? Etc.

Last edited by Harakou (2010-11-09 22:03:14)


http://www.blocks.scratchr.org/API.php?action=random&return=image&link1=http://i.imgur.com/OZn2RD3.png&link2=http://i.imgur.com/duzaGTB.png&link3=http://i.imgur.com/CrDGvvZ.png&link4=http://i.imgur.com/POEpQyZ.png&link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#2 2010-11-09 18:54:34

fullmoon
Retired Community Moderator
Registered: 2007-06-04
Posts: 1000+

Re: How do I Add Consequetive numbers In Scratch

Code:

(last number in series - first number in series + 1)*((last # + first #)/2)

So:

Code:

(100 - 1 + 1)*((100+1)/2)
100*(50.5)
5,050

Hope that helps!


http://i302.photobucket.com/albums/nn100/fullmoon32/wow.jpg

Offline

 

#3 2010-11-09 19:47:40

kayybee
Scratcher
Registered: 2009-12-07
Posts: 1000+

Re: How do I Add Consequetive numbers In Scratch

let's make two variables, v1 and v2. [blocks]
<when green flag clicked>
<set{ v1 }to( 1 )>
<set{ v2 }to( 0 )>
<repeat( 100 )>
<change{ v2 }by( v1 )>
<change{ v1 }by( 1 )>
<end>[/blocks]
That should be it. If you need help, just ask.

Last edited by kayybee (2010-11-09 21:48:27)

Offline

 

#4 2010-11-09 20:53:11

Jonathanpb
Scratcher
Registered: 2008-07-25
Posts: 1000+

Re: How do I Add Consequetive numbers In Scratch

ansman wrote:

Hi Guys,

I need your urgent response to do . How do I add the first 100 positive integer numbers in Scratch.

Hope to hear back from you soon.

Cheers

Try something like this:

[set [Number] to (0)]
[forever]
[][change [Number] by (1)]
[][add (Number) to [List]]
[end forever]


"Human beings... must have action; and they will make it if they cannot find it.
-Charlotte Brontë

Offline

 

#5 2010-11-09 20:54:34

midnightleopard
Scratcher
Registered: 2007-09-13
Posts: 1000+

Re: How do I Add Consequetive numbers In Scratch

fullmoon wrote:

Code:

(last number in series - first number in series + 1)*((last # + first #)/2)

So:

Code:

(100 - 1 + 1)*((100+1)/2)
100*(50.5)
5,050

Hope that helps!

Win for Frederick Gaus!


http://pwp.wizards.com/5103673563/Scorecards/Landscape.png

Offline

 

#6 2010-11-09 21:48:50

kayybee
Scratcher
Registered: 2009-12-07
Posts: 1000+

Re: How do I Add Consequetive numbers In Scratch

WAIT. HOW DID THIS BECOME HARAKOU'S TOPIC?!?!
Totally strange.

Offline

 

#7 2010-11-09 21:52:19

ScratchReallyROCKS
Scratcher
Registered: 2009-04-22
Posts: 1000+

Re: How do I Add Consequetive numbers In Scratch

kayybee wrote:

WAIT. HOW DID THIS BECOME HARAKOU'S TOPIC?!?!
Totally strange.

I was wondering the same thing!


http://imageshack.us/a/img694/3806/sigmad.png

Offline

 

#8 2010-11-09 21:56:47

JeanTheFox
Scratcher
Registered: 2010-06-14
Posts: 1000+

Re: How do I Add Consequetive numbers In Scratch

ScratchReallyROCKS wrote:

kayybee wrote:

WAIT. HOW DID THIS BECOME HARAKOU'S TOPIC?!?!
Totally strange.

I was wondering the same thing!

...

0.0


http://i51.tinypic.com/20gcn5j.png

Offline

 

#9 2010-11-09 22:01:35

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: How do I Add Consequetive numbers In Scratch

JeanTheFox wrote:

ScratchReallyROCKS wrote:

kayybee wrote:

WAIT. HOW DID THIS BECOME HARAKOU'S TOPIC?!?!
Totally strange.

I was wondering the same thing!

...

0.0

He made two identical topics, so they combined them. But I think it didn't work out quite right.  tongue


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

Board footer