Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fun {Prod A B}
- if A =< B then
- A|{Prod A+1 B}
- else nil
- end
- end
- fun {Sieve S}
- fun {Filter Xs K}
- case Xs of X|Xr then
- if X mod K \= 0 then
- X|{Filter Xr K}
- else {Filter Xr K}
- end
- else nil
- end
- end
- in
- case S
- of H|T then H|{Sieve thread {Filter T H} end}
- else nil
- end
- end
- fun {NotPrime S S2}
- case S of H|T then
- case S2 of X|Y then
- if X == H then {NotPrime T Y}
- elseif X < H then {NotPrime S Y}
- else H|{NotPrime T S2}
- end
- else nil
- end
- else nil
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement