tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
14
Task/Prime-decomposition/Smalltalk/prime-decomposition.st
Normal file
14
Task/Prime-decomposition/Smalltalk/prime-decomposition.st
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
Integer extend [
|
||||
primesDo: aBlock [
|
||||
| div next rest |
|
||||
div := 2. next := 3.
|
||||
rest := self.
|
||||
[ [ rest \\ div == 0 ]
|
||||
whileTrue: [
|
||||
aBlock value: div.
|
||||
rest := rest // div ].
|
||||
rest = 1] whileFalse: [
|
||||
div := next. next := next + 2 ]
|
||||
]
|
||||
]
|
||||
123456 primesDo: [ :each | each printNl ]
|
||||
Loading…
Add table
Add a link
Reference in a new issue