Skip to content

Instantly share code, notes, and snippets.

@joshuashaffer
Created October 15, 2017 16:38
Show Gist options
  • Save joshuashaffer/822f1956f0a1a153c51752a579c54dc0 to your computer and use it in GitHub Desktop.
Save joshuashaffer/822f1956f0a1a153c51752a579c54dc0 to your computer and use it in GitHub Desktop.
Get the n-th digit on the sqrt(2)
w x r=d:w(100*(x-20*r*d-d*d))(10*r+d)where d=head(filter(\d -> 20*r*d+d*d>=x)[0..])-1
nthSqrt2 n d=foldl1(++).map show.map((!!)$w 2 0)$[(1+n)..(d+n)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment