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

#1 2012-10-23 12:53:29

firedrake969_test
Scratcher
Registered: 2012-08-08
Posts: 500+

Huh?

Why doesn't this work?  Read the description.


Alt of Firedrake969.

Offline

 

#2 2012-10-23 15:58:31

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: Huh?

I think I see what's going wrong. The conditions used in your repeat loop are causing it to end too soon, and you forgot to change test by 1 in the loop, so maybe try using this instead:

when gf clicked
delete (all v) of [numbers v]
forever
 ask [What number would you like to test?] and wait
 set [numtset v] to (answer)
 set [reVal v] to [true]
 set [test v] to (2)
  if <(numtest) > (2)>
   repeat until <<((test) + (1)) = (numset)> or <(reVal) = [false]>>
    if <((numtest) mod (test)) = (0)>
     set [reVal v] to [false]
    end
   change [test v] by (1)
   end
  if <(reVal) = [false]>
   add (join (numtest) [is composite]) to [Numbers v]
  else
   add (join (numtest) [is prime]) to [Numbers v]
  end
 end
I hope that this helps!


http://i46.tinypic.com/35ismmc.png

Offline

 

#3 2012-10-23 16:29:04

mythbusteranimator
Scratcher
Registered: 2012-02-28
Posts: 1000+

Re: Huh?

You need to add "change test by one", or else it will stay at composite.  smile


http://www.foxtrot.com/comics/2012-04-01-fdb37077.gif
clicky

Offline

 

Board footer