Paste: Ugly primality testing

Author: Malcolm Reynolds
Mode: factor
Date: Mon, 1 Feb 2010 23:26:59
Plain Text |
: test-div ( n div -- ? )
    2dup swap sqrt > [
        2drop t
    ] [
        2dup rem 0 = [
            2drop f
        ] [
            1 + test-div
        ] if
    ] if ;

: is-prime? ( n -- ? )
    2 test-div ;

New Annotation

Summary:
Author:
Mode:
Body: