tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
15
Task/Prime-decomposition/Slate/prime-decomposition.slate
Normal file
15
Task/Prime-decomposition/Slate/prime-decomposition.slate
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
n@(Integer traits) primesDo: block
|
||||
"Decomposes the Integer into primes, applying the block to each (in increasing
|
||||
order)."
|
||||
[| div next remaining |
|
||||
div: 2.
|
||||
next: 3.
|
||||
remaining: n.
|
||||
[[(remaining \\ div) isZero]
|
||||
whileTrue:
|
||||
[block applyTo: {div}.
|
||||
remaining: remaining // div].
|
||||
remaining = 1] whileFalse:
|
||||
[div: next.
|
||||
next: next + 2] "Just look at the next odd integer."
|
||||
].
|
||||
Loading…
Add table
Add a link
Reference in a new issue