Skip to content

Instantly share code, notes, and snippets.

@darashi
Created January 16, 2009 10:21
Show Gist options
  • Save darashi/47891 to your computer and use it in GitHub Desktop.
Save darashi/47891 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
i = 0
founds = 0
begin
i += 1
sq = i ** 2
digits = Math.log10(sq).to_i + 1
next if digits % 2 == 1
m = 10**(digits/2)
if (sq/m - sq%m).abs == 1
founds += 1
puts "%d: %d (%d^2)" % [founds, sq, i]
end
end while founds < 21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment