Skip to content
← Back to Community
perfectSquare
Profile icon
kingTalent

Write a function called isSquare() that takes a number and tells if the number is a perfectsquare or not.

Voters
Profile icon
mikedickinson
Profile icon
alfredobustos
Profile icon
kingTalent
Comments
hotnewtop
Profile icon
jimxin2595

why tho, this is easy....

Profile icon
kingTalent

@jimxin2595 its for an interview

Profile icon
timmy_i_chen

@kingTalent Is it for your interview? ;) Do you have a solution for it?

Profile icon
kingTalent

@timmy_i_chen its there...check it out

Profile icon
timmy_i_chen

@kingTalent Where? I don't see a link

Profile icon
kingTalent
Profile icon
timmy_i_chen

@kingTalent Nice! I think there might be a way to solve this without loops - what do you think?

Profile icon
kingTalent

@timmy_i_chen yes there is.... this method seems more accurate

Profile icon
timmy_i_chen

@kingTalent I can think of a method that is equally accurate, but doesn't require loops (not as computationally expensive. e.g. if i fed the program a 20-digit number it might take a while to get there!

Profile icon
kingTalent

@timmy_i_chen you can give it a try...

Profile icon
timmy_i_chen

@kingTalent Was hoping I could get you to try it, but here it is: https://repl.it/@timmy_i_chen/isSquare

Profile icon
kingTalent

@timmy_i_chen this is acually a wrong method for checking for perfect squares.. actually forgot the issue with this method .. but i am sure its not the best approach

Profile icon
timmy_i_chen

@kingTalent Por que? Would love to hear why!

Profile icon
kingTalent

@timmy_i_chen i forgot why,but check any online resource,this method is not advisable