- 12.9k
- 2
- 71
- 55
Regex π (ECMAScript+(?*)x*+RME / PCRE2PCRE2 v10.35+), (ει€) 60 (ει€γγγΎγ§) (ει€) 59 (ει€γγγΎγ§) (ει€) 54 (ει€γγγΎγ§) 52 bytes
Attempt This Online! - PCRE2 v10.40+
RegexMathEngine : call with regex -X -xml,pq -nx -t0..17 --line-buffered -f regex.txt where regex.txt contains the regex with no newline
Regex π (ECMAScript+(?*)x*+RME / PCRE2 v10.35+), (ει€) 60 (ει€γγγΎγ§) (ει€) 59 (ει€γγγΎγ§) (ει€) 54 (ει€γγγΎγ§) 52 bytes
Attempt This Online! - PCRE2 v10.40+
RegexMathEngine : call with regex -X -xml,pq -nx -t0..17 --line-buffered -f regex.txt where regex.txt contains the regex with no newline
Regex π (PCRE2 v10.35+), (ει€) 60 (ει€γγγΎγ§) (ει€) 59 (ει€γγγΎγ§) (ει€) 54 (ει€γγγΎγ§) 52 bytes
Attempt This Online! - PCRE2 v10.40+
- 12.9k
- 2
- 71
- 55
Regex π (ECMAScript+(?*)x*+RME / PCRE2 v10.35+), (ει€) 60 (ει€γγγΎγ§) (ει€) 59 (ει€γγγΎγ§) 54(ει€) 54 (ει€γγγΎγ§) 52 bytes
^((?*(?=(xx+?)2ε*$|)((?=x2ε)(?=(x+)4ε*(4ε+$?=4ε$))5ε)*+x+)x)*$
Attempt This Online! Attempt This Online! - PCRE2 v10.40+
Try it on replit.com - ECMAScript+(?*)+x*+ (RegexMathEngineRegexMathEngine : call with regex -X -xml,pq -nx -t0..17 --line-buffered -f regex.txt) where regex.txt contains the regex with no newline
It takes the base prime \$p\$ of every prime power \$p^k\le n\$, and calculates the product of that list of numbers. And because each \$p\$ will occur \$k\$\$\max \left\{ k ,ε \middle| ,ε p^k \le n \right\}\$ times in that list, this product is the same as the product of the prime powers themselves would be, if only the largest from each base prime were included.
^ # tail = N = input number
( # Loop the following:
(?* # Non-atomic lookahead:
# M = tail, which cycles from N down to 1
(?=(xx+?)2ε*$|) # 2ε = smallest prime factor of M if M β₯ 2;
# otherwise, leave 2ε unchanged in PCRE, or
# unset in ECMAScript
(
(?=x2ε) # Keep iterating until tail β€ 2,ε and because of
# what 2ε is, this means at the end of the loop,
# either tail == 2ε (if M is a prime power) or
# tail == 1 (if M is not a prime power)
(?=(x+)4ε*(4ε+$)?=4ε$) # tail = 4ε = {largest proper divisor of tail}
# = tail / {smallest prime factor of tail};
# 5ε = tail - 4ε
5ε #/ tail{smallest =prime tailfactor -of (tail - 4ε) = 4ε}
)*+ # Iterate the above as many times as possible,
# minimum zero, and lock in the result using a
# possessive quantifier.
x+ # Multiply number of possible matches by tail
)
x # tail -= 1
)* # Loop the above a minimum of 0 times
$ # Assert that at the end of the above loop, tail == 0
Regex π (ECMAScript+(?*)x*+RME / PCRE2 v10.35+), (ει€) 60 (ει€γγγΎγ§) (ει€) 59 (ει€γγγΎγ§) 54 bytes
^((?*(?=(xx+?)2ε*$|)((?=x2ε)(?=(x+)(4ε+$))5ε)*+x+)x)*$
Attempt This Online! - PCRE2 v10.40+
Try it on replit.com - ECMAScript+(?*)+x*+ (RegexMathEngine -xml,pq)
It takes the base prime \$p\$ of every prime power \$p^k\le n\$, and calculates the product of that list of numbers. And because each \$p\$ will occur \$k\$ times in that list, this product is the same as the product of the prime powers themselves would be, if only the largest from each base prime were included.
^ # tail = N = input number
( # Loop the following:
(?* # Non-atomic lookahead:
# M = tail, which cycles from N down to 1
(?=(xx+?)2ε*$|) # 2ε = smallest prime factor of M if M β₯ 2;
# otherwise, leave 2ε unchanged in PCRE, or
# unset in ECMAScript
(
(?=x2ε) # Keep iterating until tail β€ 2,ε and because of
# what 2ε is, this means at the end of the loop,
# either tail == 2ε (if M is a prime power) or
# tail == 1 (if M is not a prime power)
(?=(x+)(4ε+$)) # 4ε = {largest proper divisor of tail}
# = tail / {smallest prime factor of tail};
# 5ε = tail - 4ε
5ε # tail = tail - (tail - 4ε) = 4ε
)*+ # Iterate the above as many times as possible,
# minimum zero, and lock in the result using a
# possessive quantifier.
x+ # Multiply number of possible matches by tail
)
x # tail -= 1
)* # Loop the above a minimum of 0 times
$ # Assert that at the end of the above loop, tail == 0
Regex π (ECMAScript+(?*)x*+RME / PCRE2 v10.35+), (ει€) 60 (ει€γγγΎγ§) (ει€) 59 (ει€γγγΎγ§) (ει€) 54 (ει€γγγΎγ§) 52 bytes
^((?*(?=(xx+?)2ε*$|)((?=x2ε)(x+)4ε*(?=4ε$))*+x+)x)*$
Attempt This Online! - PCRE2 v10.40+
RegexMathEngine : call with regex -X -xml,pq -nx -t0..17 --line-buffered -f regex.txt where regex.txt contains the regex with no newline
It takes the base prime \$p\$ of every prime power \$p^k\le n\$, and calculates the product of that list of numbers. And because each \$p\$ will occur \$\max \left\{ k ,ε \middle| ,ε p^k \le n \right\}\$ times in that list, this product is the same as the product of the prime powers themselves would be, if only the largest from each base prime were included.
^ # tail = N = input number
( # Loop the following:
(?* # Non-atomic lookahead:
# M = tail, which cycles from N down to 1
(?=(xx+?)2ε*$|) # 2ε = smallest prime factor of M if M β₯ 2;
# otherwise, leave 2ε unchanged in PCRE, or
# unset in ECMAScript
(
(?=x2ε) # Keep iterating until tail β€ 2,ε and because of
# what 2ε is, this means at the end of the loop,
# either tail == 2ε (if M is a prime power) or
# tail == 1 (if M is not a prime power)
(x+)4ε*(?=4ε$) # tail = 4ε = {largest proper divisor of tail}
# = tail / {smallest prime factor of tail}
)*+ # Iterate the above as many times as possible,
# minimum zero, and lock in the result using a
# possessive quantifier.
x+ # Multiply number of possible matches by tail
)
x # tail -= 1
)* # Loop the above a minimum of 0 times
$ # Assert that at the end of the above loop, tail == 0
- 12.9k
- 2
- 71
- 55
Regex π (ECMAScript+(?*)+()++x*+RME RME / PCRE2 v10.35+), (ει€) 60 (ει€γγγΎγ§) (ει€) 59 (ει€γγγΎγ§) 54 bytes
Attempt This Online! - PCRE2 v10.40+
Try it on replit.com - ECMAScript+(?*)+()++x*+ (RegexMathEngine -xml,pq)
Regex π (ECMAScript+(?*)+()++RME / PCRE2 v10.35+), (ει€) 60 (ει€γγγΎγ§) (ει€) 59 (ει€γγγΎγ§) 54 bytes
Attempt This Online! - PCRE2 v10.40+
Try it on replit.com - ECMAScript+(?*)+()++ (RegexMathEngine -xml,pq)
Regex π (ECMAScript+(?*)x*+RME / PCRE2 v10.35+), (ει€) 60 (ει€γγγΎγ§) (ει€) 59 (ει€γγγΎγ§) 54 bytes
Attempt This Online! - PCRE2 v10.40+
Try it on replit.com - ECMAScript+(?*)+x*+ (RegexMathEngine -xml,pq)
- 12.9k
- 2
- 71
- 55
- 12.9k
- 2
- 71
- 55
- 12.9k
- 2
- 71
- 55
- 12.9k
- 2
- 71
- 55
- 12.9k
- 2
- 71
- 55
- 12.9k
- 2
- 71
- 55
- 12.9k
- 2
- 71
- 55