You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

29 lines
506 B

" Smalltalk version of a prime number finder
<haplo@mindstab.net>"
| Max |
Smalltalk arguments size < 1
ifTrue: [
'Usage: primes.st [Max]' printNl.
]
ifFalse: [
Max := (Smalltalk arguments at: 1) asInteger.
3 to: Max by: 2 do: [ :number |
LowMax := (number sqrt) rounded.
IsPrime := true.
3 to: LowMax by: 2 do: [ :factor |
((number rem: factor) == 0)
ifTrue: [
IsPrime := false
]
].
IsPrime
ifTrue: [
number printNl
]
]
].
!