let rec genlist n k =
if k <= n then k :: genlist n (k+1)
else [] ;;
let allnums n = genlist n 2 ;;
let rec rest k l =
match l with
[] -> [] |
h :: t when h mod k = 0 -> rest k t |
h :: t -> h :: rest k t ;;
let rec sieve l =
match l with
[] -> [] |
h :: t -> h :: sieve (rest h t) ;;
let primzahlen n = sieve (allnums n) ;;