Skip to content

Instantly share code, notes, and snippets.

@koher
Last active February 19, 2023 13:01
Show Gist options
  • Save koher/6079d3e36a65d685ce19df537bc79d05 to your computer and use it in GitHub Desktop.
Save koher/6079d3e36a65d685ce19df537bc79d05 to your computer and use it in GitHub Desktop.
// https://twitter.com/koher/status/1627284858493075463
for n in 2 ... 1000000 {
var a = n * n - 1
while a.isMultiple(of: 2) {
a /= 2
}
while a.isMultiple(of: 5) {
a /= 5
}
guard a == 1 else { continue }
var b = n * 10
while !b.isMultiple(of: n * n - 1) {
b *= 10
}
print(n, b / (n * n - 1))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment