Jump to content

Miller–Rabin primality test: Difference between revisions

m
Line 922:
% and augmented number of deterministic proving bases.
% Deleted first_1000/0 because not used.
% Modified, January 26, 2014 @ 1011:50am04am PST.
 
is_prime(1) -> false;
Line 955:
is_mr_prime(N, As) when N>2, N rem 2 == 1 ->
{D, S} = find_ds(N),
%% this is a test for compositedness; the first two case patterns disprove
%% compositedness, while the third proves compositedness and thereby
%% foreshortens some searches while increasing execution time for others
not lists:any(fun(A) ->
case mr_series(N, A, D, S) of
[1|_] -> false;
L -> not lists:member(N-1, L);
[_|T] -> lists:member(1, T) % foreshortens some searches
end
end,
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.