Skip to content

Instantly share code, notes, and snippets.

@Gonster
Last active August 27, 2015 03:54
Show Gist options
  • Save Gonster/20f1de52008286f813ba to your computer and use it in GitHub Desktop.
Save Gonster/20f1de52008286f813ba to your computer and use it in GitHub Desktop.
hola crystal lang
def pow(x,y)
return 1 if y == 0 || x == 1
r = 1
if y > 0
return 0 if x == 0
while y > 0
r *= x
y -= 1
end
else
return "Infinite" if x == 0
while y < 0
r /= x
y += 1
end
end
return r
end
puts pow(1,100)
puts pow(0,10)
puts pow(2,32)
puts pow(2,-10)
puts pow(0,-4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment