Skip to content

Instantly share code, notes, and snippets.

@edr3x
Created February 16, 2024 11:39
Show Gist options
  • Save edr3x/00a85cf379a9669b823cd6df8a05cff3 to your computer and use it in GitHub Desktop.
Save edr3x/00a85cf379a9669b823cd6df8a05cff3 to your computer and use it in GitHub Desktop.
Function to check if a number is a power of another number in GO
func isPower(number int, isPowerOf int) bool {
if number < 1 {
return false
}
if number%isPowerOf == 0 {
return isPower(number/isPowerOf, isPowerOf)
}
return number == 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment