Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
22
Task/Almost-prime/SequenceL/almost-prime.sequencel
Normal file
22
Task/Almost-prime/SequenceL/almost-prime.sequencel
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import <Utilities/Conversion.sl>;
|
||||
import <Utilities/Sequence.sl>;
|
||||
|
||||
main(args(2)) :=
|
||||
let
|
||||
result := firstNKPrimes(1 ... 5, 10);
|
||||
|
||||
output[i] := "k = " ++ intToString(i) ++ ": " ++ delimit(intToString(result[i]), ' ');
|
||||
in
|
||||
delimit(output, '\n');
|
||||
|
||||
firstNKPrimes(k, N) := firstNKPrimesHelper(k, N, 2, []);
|
||||
|
||||
firstNKPrimesHelper(k, N, current, result(1)) :=
|
||||
let
|
||||
newResult := result when not isKPrime(k, current) else result ++ [current];
|
||||
in
|
||||
result when size(result) = N
|
||||
else
|
||||
firstNKPrimesHelper(k, N, current + 1, newResult);
|
||||
|
||||
isKPrime(k, n) := size(primeFactorization(n)) = k;
|
||||
Loading…
Add table
Add a link
Reference in a new issue