Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
5
Task/Emirp-primes/Smalltalk/emirp-primes-1.st
Normal file
5
Task/Emirp-primes/Smalltalk/emirp-primes-1.st
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
isEmirp :=
|
||||
[:p | |e|
|
||||
(e := p asString reversed asNumber) isPrime
|
||||
and:[ e ~= p ]
|
||||
].
|
||||
4
Task/Emirp-primes/Smalltalk/emirp-primes-2.st
Normal file
4
Task/Emirp-primes/Smalltalk/emirp-primes-2.st
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
primeGen :=
|
||||
[:n |
|
||||
LazyCons car:n cdr:[primeGen value:(n nextPrime)]
|
||||
].
|
||||
6
Task/Emirp-primes/Smalltalk/emirp-primes-3.st
Normal file
6
Task/Emirp-primes/Smalltalk/emirp-primes-3.st
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
emirpGen :=
|
||||
[:l | |rest el|
|
||||
rest := l.
|
||||
[ el := rest car. rest := rest cdr. isEmirp value:el ] whileFalse.
|
||||
LazyCons car:el cdr:[emirpGen value:rest]
|
||||
].
|
||||
2
Task/Emirp-primes/Smalltalk/emirp-primes-4.st
Normal file
2
Task/Emirp-primes/Smalltalk/emirp-primes-4.st
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
listOfPrimes := primeGen value:2.
|
||||
listOfEmirps := emirpGen value:listOfPrimes.
|
||||
11
Task/Emirp-primes/Smalltalk/emirp-primes-5.st
Normal file
11
Task/Emirp-primes/Smalltalk/emirp-primes-5.st
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
Transcript
|
||||
show:'first 20 emirps: ';
|
||||
showCR:(listOfEmirps take:20) asArray.
|
||||
|
||||
Transcript
|
||||
show:'emirps between 7700 and 8000 are: ';
|
||||
showCR:((7700 to:8000) select:[:n | n isPrime and:[isEmirp value:n]]).
|
||||
|
||||
Transcript
|
||||
show:'10000''th emirp: ';
|
||||
showCR:(listOfEmirps nth:10000).
|
||||
18
Task/Emirp-primes/Smalltalk/emirp-primes-6.st
Normal file
18
Task/Emirp-primes/Smalltalk/emirp-primes-6.st
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
Object subclass: #Cons
|
||||
instancevariableNames:'car cdr'.
|
||||
|
||||
car:newCar cdr:newCdr
|
||||
car := newCar. cdr := newCdr
|
||||
|
||||
car
|
||||
^car
|
||||
|
||||
cdr
|
||||
^cdr
|
||||
|
||||
Cons subclass:#LazyCons
|
||||
|
||||
cdr
|
||||
cdr := cdr value.
|
||||
self changeClassTo:Cons.
|
||||
^cdr
|
||||
Loading…
Add table
Add a link
Reference in a new issue