Skip to content

Instantly share code, notes, and snippets.

@yurighensev
Created October 7, 2016 15:38
Show Gist options
  • Save yurighensev/93138cccbe346422a44f841d471d0603 to your computer and use it in GitHub Desktop.
Save yurighensev/93138cccbe346422a44f841d471d0603 to your computer and use it in GitHub Desktop.
def sol_equa(n)
sol = []
(n/4.0).floor.downto(0) do |y|
begin
x = Math.sqrt(n + 4 * y**2)
sol.push [x.to_i, y.to_i] if x.to_i == x
rescue => e
break
end
end
sol
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment