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

Misread question, fixed input handling.
Source Link

05AB1E, 5 bytes

LDp*OŸDp*O

Try it online! Try it online!

LŸ Push the list [1[a,...,input] b]
 D Push a duplicate of that list
 p Replace primes with 1 and everything else with 0
 * Element-wise multiply the two lists [1*0, 2*1, 3*1, 4*0, ...]
 O Sum of the final list of primes

05AB1E, 5 bytes

LDp*O

Try it online!

L Push the list [1,...,input]
 D Push a duplicate of that list
 p Replace primes with 1 and everything else with 0
 * Element-wise multiply the two lists [1*0, 2*1, 3*1, 4*0, ...]
 O Sum of the final list of primes

05AB1E, 5 bytes

ŸDp*O

Try it online!

Ÿ Push the list [a,..., b]
 D Push a duplicate of that list
 p Replace primes with 1 and everything else with 0
 * Element-wise multiply the two lists [1*0, 2*1, 3*1, 4*0, ...]
 O Sum of the final list of primes
Source Link

05AB1E, 5 bytes

LDp*O

Try it online!

L Push the list [1,...,input]
 D Push a duplicate of that list
 p Replace primes with 1 and everything else with 0
 * Element-wise multiply the two lists [1*0, 2*1, 3*1, 4*0, ...]
 O Sum of the final list of primes

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