Skip to content

Instantly share code, notes, and snippets.

@pollardld
Last active June 19, 2023 20:04
Show Gist options
  • Save pollardld/dc21f6380beaa88488daaab3fdb7ef28 to your computer and use it in GitHub Desktop.
Save pollardld/dc21f6380beaa88488daaab3fdb7ef28 to your computer and use it in GitHub Desktop.
Algorithms from speedcoder.net

Check if a number is a perfect square

import math

number = int(input())
square_number = int(math.sqrt(number))

if (number == square_number * square_number):
    print("perfect square: %d * %d = %d"%(square_number,square_number,number))
else:
    print("not perfect square")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment