Pyth, 21 bytes
@*6cQ/iMcmhO^T6yQ2lN2
Explanation
Q input number
y twice that
m map numbers 0 to n-1:
T 10
^ 6 to the 6th power
O random number from 0 to n-1
h add one
c 2 split into pairs
iM gcd of each pair
/ lN count ones
cQ divide input number by the result
*6 multiply by 6
@ 2 square root
PurkkaKoodari
- 17.9k
- 2
- 37
- 92