HELP ON TURING- PERFECT SQUARE
Author |
Message |
dinktsr
|
Posted: Mon Apr 26, 2004 5:05 pm Post subject: HELP ON TURING- PERFECT SQUARE |
|
|
i struggle so much at this it's not even funny...
i need a program that keep inputting integers until a perfect square (ex. 81, 9) between 40 and 100
PLEASE HELP ME, WITHOUT THIS IM DEAD, THANKS IN ADVANCE |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
|
|
|
![](images/spacer.gif) |
Paul
![](http://i12.photobucket.com/albums/a207/paulbian/DDRDuck.png)
|
Posted: Mon Apr 26, 2004 5:17 pm Post subject: (No subject) |
|
|
wha...?
here's how I would do it, it might be sucky, but i always like to showoff my newly learned knowledge (strintok)
code: |
for a: 40..100
if strintok (realstr(sqrt (a),0))then
put a
exit
else
put a, " "..
end if
end for
|
|
|
|
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Mon Apr 26, 2004 5:18 pm Post subject: (No subject) |
|
|
hah, while we at it, might also use if sqrt(num) mod 1 = 0 to test for a perfect square ![Laughing Laughing](http://compsci.ca/v3/images/smiles/icon_lol.gif) |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
|
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Mon Apr 26, 2004 5:38 pm Post subject: (No subject) |
|
|
Cervantes - since round drops the decimal point, when you square the number it will not be the same as the one you squared.
It is basically a test to see if the squareroot of a number is an integer (perfect square) or not. That's why I later posted with mod 1 method, as non integer root will have a .something remainder.
10 (non perfect square) sqrt = 3.16
round(3.16) = 3
3 * 3 = 9
9 != 10
![Wink Wink](http://compsci.ca/v3/images/smiles/icon_wink.gif) |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
Posted: Mon Apr 26, 2004 5:49 pm Post subject: (No subject) |
|
|
i have an incredibly strong urge to edit my above post and erase all my moronic ramblings ![Embarassed Embarassed](http://compsci.ca/v3/images/smiles/icon_redface.gif) |
|
|
|
|
![](images/spacer.gif) |
|
|