Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

added 649 characters in body
Source Link
Dennis
  • 211.7k
  • 41
  • 380
  • 830

Jelly, (削除) 15 (削除ここまで) 14 bytes

’ÆRμ_2fμ+2;μİS

Try it online! Try it online!

How it works

’ÆRμ_2fμ+2;μİS Main link. Argument: n
’ Decrement; yield n-1.
 ÆR Prime range; yield all primes in [1, ..., n-1].
 μ New chain. Argument: r (prime range)
 _2 Subtract 2 from all primes.
 f Filter; keep all p-2 that appear in r.
 μ New chain. Argument: t (filtered range)
 +2 Add 2 to all primes in s.
 ; Concatenate with s.
 μ New chain. Argument: t (twin primes)
 İ Take the inverses.
 S Sum.

Jelly, (削除) 15 (削除ここまで) 14 bytes

’ÆRμ_2fμ+2;μİS

Try it online!

Jelly, (削除) 15 (削除ここまで) 14 bytes

’ÆRμ_2fμ+2;μİS

Try it online!

How it works

’ÆRμ_2fμ+2;μİS Main link. Argument: n
’ Decrement; yield n-1.
 ÆR Prime range; yield all primes in [1, ..., n-1].
 μ New chain. Argument: r (prime range)
 _2 Subtract 2 from all primes.
 f Filter; keep all p-2 that appear in r.
 μ New chain. Argument: t (filtered range)
 +2 Add 2 to all primes in s.
 ; Concatenate with s.
 μ New chain. Argument: t (twin primes)
 İ Take the inverses.
 S Sum.
added 5 characters in body
Source Link
Dennis
  • 211.7k
  • 41
  • 380
  • 830

Jelly, 15(削除) 15 (削除ここまで) 14 bytes

Ḷ_0,2ドルÆPẠ$ÐfFİS’ÆRμ_2fμ+2;μİS

Try it online! Try it online!

Jelly, 15 bytes

Ḷ_0,2ドルÆPẠ$ÐfFİS

Try it online!

Jelly, (削除) 15 (削除ここまで) 14 bytes

’ÆRμ_2fμ+2;μİS

Try it online!

Source Link
Dennis
  • 211.7k
  • 41
  • 380
  • 830

Jelly, 15 bytes

Ḷ_0,2ドルÆPẠ$ÐfFİS

Try it online!

AltStyle によって変換されたページ (->オリジナル) /