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

Commonmark migration
Source Link

#APL NARS, 216 bytes, 108 chars

APL NARS, 216 bytes, 108 chars

 r←z n;h;i;k;v
 i←0⋄n-←1⋄h←1+⍳n-1⋄→B
A:k←i⊃h⋄h←k∪(0≠k∣h)×ばつ⍳(⍴h)≥i+←1
 r←+/÷(v-2),v←(h=1⌽h+2)/h

this would use the "Crivello di Eratostene" for find the sublist in 1..arg of request primes. Test:

 z ̈2 6 10 13 100 620
0 0.5333333333 0.8761904762 0.8761904762 1.330990366 1.499970603 
 z 100000
1.672799585

#APL NARS, 216 bytes, 108 chars

 r←z n;h;i;k;v
 i←0⋄n-←1⋄h←1+⍳n-1⋄→B
A:k←i⊃h⋄h←k∪(0≠k∣h)×ばつ⍳(⍴h)≥i+←1
 r←+/÷(v-2),v←(h=1⌽h+2)/h

this would use the "Crivello di Eratostene" for find the sublist in 1..arg of request primes. Test:

 z ̈2 6 10 13 100 620
0 0.5333333333 0.8761904762 0.8761904762 1.330990366 1.499970603 
 z 100000
1.672799585

APL NARS, 216 bytes, 108 chars

 r←z n;h;i;k;v
 i←0⋄n-←1⋄h←1+⍳n-1⋄→B
A:k←i⊃h⋄h←k∪(0≠k∣h)×ばつ⍳(⍴h)≥i+←1
 r←+/÷(v-2),v←(h=1⌽h+2)/h

this would use the "Crivello di Eratostene" for find the sublist in 1..arg of request primes. Test:

 z ̈2 6 10 13 100 620
0 0.5333333333 0.8761904762 0.8761904762 1.330990366 1.499970603 
 z 100000
1.672799585
added 95 characters in body
Source Link
user58988
user58988

#APL NARS, 216 bytes, 108 chars

 r←z n;h;i;k;v
 i←0⋄n-←1⋄h←1+⍳n-1⋄→B
A:k←i⊃h⋄h←k∪(0≠k∣h)×ばつ⍳(⍴h)≥i+←1
 r←+/÷(v-2),v←(h=1⌽h+2)/h

testthis would use the "Crivello di Eratostene" for find the sublist in 1..arg of request primes. Test:

 z ̈2 6 10 13 100 620
0 0.5333333333 0.8761904762 0.8761904762 1.330990366 1.499970603 
 z 100000
1.672799585

#APL NARS, 216 bytes, 108 chars

 r←z n;h;i;k;v
 i←0⋄n-←1⋄h←1+⍳n-1⋄→B
A:k←i⊃h⋄h←k∪(0≠k∣h)×ばつ⍳(⍴h)≥i+←1
 r←+/÷(v-2),v←(h=1⌽h+2)/h

test

 z ̈2 6 10 13 100 620
0 0.5333333333 0.8761904762 0.8761904762 1.330990366 1.499970603 
 z 100000
1.672799585

#APL NARS, 216 bytes, 108 chars

 r←z n;h;i;k;v
 i←0⋄n-←1⋄h←1+⍳n-1⋄→B
A:k←i⊃h⋄h←k∪(0≠k∣h)×ばつ⍳(⍴h)≥i+←1
 r←+/÷(v-2),v←(h=1⌽h+2)/h

this would use the "Crivello di Eratostene" for find the sublist in 1..arg of request primes. Test:

 z ̈2 6 10 13 100 620
0 0.5333333333 0.8761904762 0.8761904762 1.330990366 1.499970603 
 z 100000
1.672799585
Source Link
user58988
user58988

#APL NARS, 216 bytes, 108 chars

 r←z n;h;i;k;v
 i←0⋄n-←1⋄h←1+⍳n-1⋄→B
A:k←i⊃h⋄h←k∪(0≠k∣h)×ばつ⍳(⍴h)≥i+←1
 r←+/÷(v-2),v←(h=1⌽h+2)/h

test

 z ̈2 6 10 13 100 620
0 0.5333333333 0.8761904762 0.8761904762 1.330990366 1.499970603 
 z 100000
1.672799585

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