Skip to content
Advertisement

How to find out if a number is a perfect square without using sqrt function or ** in Python? [duplicate]

I have to write a program that finds out whether or not a number is a perfect square. The terms are I don’t use a sqrt function or an exponent (**)

I previously showed my teacher my solution using exponent (**) and she told me not to include that there.

JavaScript

It works fine with perfect squares but when they’re not, it won’t work because I can’t find a way to get it out of the while loop even though it’s not a perfect square.

Advertisement

Answer

You have to change

JavaScript

to

JavaScript

and it will work.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement