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

#J, 27 Bytes

J, 27 Bytes

3 :'%:6*y%+/(1:=?+.?)y#1e6'

Explanation:

3 :' ' | Explicit verb definition
 y#1e6 | List of y copies of 1e6 = 1000000
 (1:=?+.?) | for each item, generate i and j, and test whether their gcd is 1
 +/ | Sum the resulting list
 6*y% | Divide y by it and multiply by six
 %: | Square root

Got pretty lucky with a 3.14157 for N = 10000000, which took 2.44 seconds.

#J, 27 Bytes

3 :'%:6*y%+/(1:=?+.?)y#1e6'

Explanation:

3 :' ' | Explicit verb definition
 y#1e6 | List of y copies of 1e6 = 1000000
 (1:=?+.?) | for each item, generate i and j, and test whether their gcd is 1
 +/ | Sum the resulting list
 6*y% | Divide y by it and multiply by six
 %: | Square root

Got pretty lucky with a 3.14157 for N = 10000000, which took 2.44 seconds.

J, 27 Bytes

3 :'%:6*y%+/(1:=?+.?)y#1e6'

Explanation:

3 :' ' | Explicit verb definition
 y#1e6 | List of y copies of 1e6 = 1000000
 (1:=?+.?) | for each item, generate i and j, and test whether their gcd is 1
 +/ | Sum the resulting list
 6*y% | Divide y by it and multiply by six
 %: | Square root

Got pretty lucky with a 3.14157 for N = 10000000, which took 2.44 seconds.

Source Link

#J, 27 Bytes

3 :'%:6*y%+/(1:=?+.?)y#1e6'

Explanation:

3 :' ' | Explicit verb definition
 y#1e6 | List of y copies of 1e6 = 1000000
 (1:=?+.?) | for each item, generate i and j, and test whether their gcd is 1
 +/ | Sum the resulting list
 6*y% | Divide y by it and multiply by six
 %: | Square root

Got pretty lucky with a 3.14157 for N = 10000000, which took 2.44 seconds.

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