SHARE
TWEET

Untitled

a guest Feb 19th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # \1 = biggest prime factor of N
  2. (?= (xx+) \1* (?!(xx+)\2+$) \1$ )
  3.  
  4. (?=
  5.         # Main loop!
  6.         (
  7.                 # \4 = N % \1, N -= \4
  8.                 (x*?) (?=\1*$)
  9.  
  10.                 # \5 = next prime factor of N
  11.                 (?= (\4xx+?) (\5* (?!(xx+)\7+$) \5)? $ )
  12.  
  13.                 # \8 = B, \9 = B - 1, \10 = N - B
  14.                 (?= ((x*) (?=\5\9*$) x) (\8*) $ )
  15.  
  16.                 x*
  17.                 (?=
  18.                         # if \5 = \1, break.
  19.                         (?=\5$) \1
  20.                 |
  21.                         # else, N = (\5 - 1) + (N - B)
  22.                         \5\10
  23.                 )
  24.                 x
  25.         )*
  26. ) \10
  27.  
  28. # Special-case: if N prime, return N-1
  29. | x+\B
  30.  
  31. # Special-case: if N is 1, return 1
  32. | x
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top