Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # \1 = biggest prime factor of N
- (?= (xx+) \1* (?!(xx+)\2+$) \1$ )
- (?=
- # Main loop!
- (
- # \4 = N % \1, N -= \4
- (x*?) (?=\1*$)
- # \5 = next prime factor of N
- (?= (\4xx+?) (\5* (?!(xx+)\7+$) \5)? $ )
- # \8 = B, \9 = B - 1, \10 = N - B
- (?= ((x*) (?=\5\9*$) x) (\8*) $ )
- x*
- (?=
- # if \5 = \1, break.
- (?=\5$) \1
- |
- # else, N = (\5 - 1) + (N - B)
- \5\10
- )
- x
- )*
- ) \10
- # Special-case: if N prime, return N-1
- | x+\B
- # Special-case: if N is 1, return 1
- | x
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement