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

edited body
Source Link
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382

MATL, 22 bytes

1e6HiI$YrZ1e6Hi3$YrZ}Zd1=Ym6w/X^

Try it online! Try it online!

1e6 % Push 1e6
H % Push 2
i % PusnPush input, N
I$Yr3$Yr % ×ばつN matrix of uniformly random integer values between 1 and 1e6
Z} % Split ontointo its two rows. Gives two ×ばつN arrays
Zd % GCD, element-wise. Gives a ×ばつN array
1= % Compare each entry with 1. Sets 1 to 0, and other values to 0
Ym % Mean of the array
6w/ % 6 divided by that
X^ % Square root. Implicitly display

MATL, 22 bytes

1e6HiI$YrZ}Zd1=Ym6w/X^

Try it online!

1e6 % Push 1e6
H % Push 2
i % Pusn input, N
I$Yr % ×ばつN matrix of uniformly random integer values between 1 and 1e6
Z} % Split onto its two rows
Zd % GCD, element-wise
1= % Compare each entry with 1. Sets 1 to 0, and other values to 0
Ym % Mean of the array
6w/ % 6 divided by that
X^ % Square root. Implicitly display

MATL, 22 bytes

1e6Hi3$YrZ}Zd1=Ym6w/X^

Try it online!

1e6 % Push 1e6
H % Push 2
i % Push input, N
3$Yr % ×ばつN matrix of uniformly random integer values between 1 and 1e6
Z} % Split into its two rows. Gives two ×ばつN arrays
Zd % GCD, element-wise. Gives a ×ばつN array
1= % Compare each entry with 1. Sets 1 to 0, and other values to 0
Ym % Mean of the array
6w/ % 6 divided by that
X^ % Square root. Implicitly display
Post Undeleted by Luis Mendo
deleted 15 characters in body
Source Link
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382

MATL, 2122 bytes

6iH1e6I$YrZ1e6HiI$YrZ}Zd1=YmZd1=Ym6w/X^

Try it online! Try it online!

6 1e6 % Push 6
i  % Input N1e6
H % Push 2
1e6i  % PushPusn 1e6input, N
I$Yr % ×ばつ1e6×ばつN matrix of uniformly random integer values between 1 and N1e6
Z} % Split onto its two rows
Zd % GCD, element-wise
1= % Compare each entry with 1. Sets 1 to 0, and other values to 0
Ym % Mean of the array
6w/ % Divide 6 bydivided theby resultthat
X^ % Square root. Implicitly display

MATL, 21 bytes

6iH1e6I$YrZ}Zd1=Ym/X^

Try it online!

6  % Push 6
i  % Input N
H % Push 2
1e6 % Push 1e6
I$Yr % ×ばつ1e6 matrix of uniformly random integer values between 1 and N
Z} % Split onto its two rows
Zd % GCD, element-wise
1= % Compare each entry with 1. Sets 1 to 0, and other values to 0
Ym % Mean of the array
/ % Divide 6 by the result
X^ % Square root. Implicitly display

MATL, 22 bytes

1e6HiI$YrZ}Zd1=Ym6w/X^

Try it online!

1e6 % Push 1e6
H % Push 2
i  % Pusn input, N
I$Yr % ×ばつN matrix of uniformly random integer values between 1 and 1e6
Z} % Split onto its two rows
Zd % GCD, element-wise
1= % Compare each entry with 1. Sets 1 to 0, and other values to 0
Ym % Mean of the array
6w/ % 6 divided by that
X^ % Square root. Implicitly display
Post Deleted by Luis Mendo
added 450 characters in body
Source Link
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382

MATL, 21 bytes

6iH1e6I$YrZ}Zd1=Ym/X^

Try it online!

6 % Push 6
i % Input N
H % Push 2
1e6 % Push 1e6
I$Yr % ×ばつ1e6 matrix of uniformly random integer values between 1 and N
Z} % Split onto its two rows
Zd % GCD, element-wise
1= % Compare each entry with 1. Sets 1 to 0, and other values to 0
Ym % Mean of the array
/ % Divide 6 by the result
X^ % Square root. Implicitly display

MATL, 21 bytes

6iH1e6I$YrZ}Zd1=Ym/X^

Try it online!

MATL, 21 bytes

6iH1e6I$YrZ}Zd1=Ym/X^

Try it online!

6 % Push 6
i % Input N
H % Push 2
1e6 % Push 1e6
I$Yr % ×ばつ1e6 matrix of uniformly random integer values between 1 and N
Z} % Split onto its two rows
Zd % GCD, element-wise
1= % Compare each entry with 1. Sets 1 to 0, and other values to 0
Ym % Mean of the array
/ % Divide 6 by the result
X^ % Square root. Implicitly display
Source Link
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382
Loading

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