     1 + 6 divisor? ;
 
 : next-safe-prime-candidate ( n -- candidate )
-    1 - 2/
     next-prime dup safe-prime-candidate?
     [ next-safe-prime-candidate ] unless ;
 

    dup miller-rabin
    [ nip ] [ drop next-safe-prime ] if ;

: random-safe-prime ( numbits -- p )
    random-bits next-safe-prime ;

! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: combinators kernel locals math math.functions math.ranges
random sequences sets combinators.short-circuit math.bitwise ;
IN: math.miller-rabin

<PRIVATE
