Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fun {Prod M N}
- if M=<N then M|{Prod M+1 N}
- else nil
- end
- end
- fun {Sieve P}
- local
- fun {Maxo P Acc}
- case P of H|T then
- if H>Acc then {Maxo T H}
- else {Maxo T Acc}
- end
- else Acc
- end
- end
- fun{Divido P K}
- case P of H|T then
- if H==1 then H|{Divido T K}
- elseif H==K orelse H mod K \= 0 then H|{Divido T K}
- else {Divido T K}
- end
- else nil
- end
- end
- fun {Listo P K Max}
- case P of H|T then
- if K=<Max then {Listo {Divido P K} K+1 Max}
- else P
- end
- else nil
- end
- end
- in
- {Listo P 2 {Maxo P 0}}
- end
- end
- fun{NotPrime S1 S2}
- local
- fun{Removo P El}
- case P of H|T then
- if H==El then {Removo T El}
- else H|{Removo T El}
- end
- else nil
- end
- end
- fun{Listo P Q}
- case Q of H|T then
- {Listo {Removo P H} T}
- else
- P
- end
- end
- in
- {Listo S1 S2}
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement