Files
project_euler/37/main.ua
2025-08-30 11:11:26 +02:00

19 lines
947 B
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# project euler 37
# many of the same primality checks, so memo
# n ? is_prime(n)
p ← memo(=1⧻°/×)
# by picking sufficiently large n (n > ~800000),
# all such primes will be found.
n ← 800000
▽⊸≡p+8⇡n # find primes below n, skipping first 7
▽⊸≡(
# keep those that satisfy
⊃⍜⇌⧅(⋕⇌)⧅⋕ °⋕ # (1) prefixes; and (2) suffixes
↧∩(/↧≡p) # are all prime
)
/+ # sum primes
# online pad
# https://www.uiua.org/pad?src=0_17_0-dev_2__IyBwcm9qZWN0IGV1bGVyIDM3CiMgbWFueSBvZiB0aGUgc2FtZSBwcmltYWxpdHkgY2hlY2tzLCBzbyBtZW1vCiMgbiA_IGlzX3ByaW1lKG4pCnAg4oaQIG1lbW8oPTHip7vCsC_DlykKCm4g4oaQIDEwMDAK4pa94oq44omhcCs44oehbiAjIGZpbmQgcHJpbWVzIGJlbG93IG4sIHNraXBwaW5nIGZpcnN0IDcK4pa94oq44omhKAogICMga2VlcCB0aG9zZSB0aGF0IHNhdGlzZnkKICDiioPijZzih4zip4Uo4ouV4oeMKeKnheKLlSDCsOKLlSAjICgxKSBwcmVmaXhlczsgYW5kICgyKSBzdWZmaXhlcwogIOKGp-KIqSgv4oan4omhcCkgICAgICAjIGFyZSBhbGwgcHJpbWUKKQovK-KfnOKnuyAjIHN1bSBhbmQgY291bnQK