Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Finding a square root
- CatClawz_
-
500+ posts
Finding a square root
writing some code to find a square root of a number (I get that there's probably a block for that, I'm just doing this for fun) I think I can do it but I'm having trouble making a start. Can someone give me a point in the right direction? 

- Malicondi
-
1000+ posts
Finding a square root
i would recommend having a list of each perfect square (you can simply add this as show below) and a simple formula for calculating the approximate of a non perfect square would be using this formula:
√x = √y + ((x - y) / ((2) * (√y))
where y is the closest perfect square to x, and x is any number.
for adding in square roots of up to 100^2:
√x = √y + ((x - y) / ((2) * (√y))
where y is the closest perfect square to x, and x is any number.
for adding in square roots of up to 100^2:
Hope this helps! if you need anything else just reply to this and i'll see it.
they said they know, they're doing this for fun. There's already a block for this.
Last edited by Malicondi (March 1, 2024 21:44:47)
- EDawg2011
-
1000+ posts
Finding a square root
They said probably, so they probably didn't know it existed.they said they know, they're doing this for fun. There's already a block for this.
- homewins
-
47 posts
Finding a square root
Google “Heron's method for square roots”
Last edited by homewins (March 2, 2024 22:15:40)
- CatClawz_
-
500+ posts
Finding a square root
thanks everyone! I think I've got it now 
and yeah I'm not sure why i said probably I know there's a block for it loll

and yeah I'm not sure why i said probably I know there's a block for it loll
- deck26
-
1000+ posts
Finding a square root
I didn't know there was a name for that method but it always seemed fairly intuitive to me and I've used that method for years without ever being taught it. After all if you have two positive factors and one is below the square root the other has to be greater than the square root. Think of a rectangle with those sides where the area is the value we're trying to find the square root of. Taking the average of the two values and dividing into the area will give us a rectangle with the same area that is closer to a square. Google “Heron's method for square roots”
But I see it goes back around 2000 years when obviously mathematical knowledge was much less widespread. It is also known by multiple names.
- CatClawz_
-
500+ posts
Finding a square root
approximate of a non perfect square would be using this formula:This is a good idea, although it only goes up to 100, how would i find the square root of a number over 100², like 10201, using this method? i would recommend having a list of each perfect square (you can simply add this as show below) and a simple formula for calculating the
√x = √y + ((x - y) / ((2) * (√y))
where y is the closest perfect square to x, and x is any number.
for adding in square roots of up to 100^2:Hope this helps! if you need anything else just reply to this and i'll see it.they said they know, they're doing this for fun. There's already a block for this.
- Discussion Forums
- » Help with Scripts
-
» Finding a square root