Quizzes & Puzzles1 min ago
Answers
No best answer has yet been selected by cavendish. Once a best answer has been selected, it will be shown here.
For more on marking an answer as the "Best Answer", please visit our FAQ.(That translates as "I can't make head nor tail of your posts")
http://www.stevie21.com/AB/prime.asp
stevie21, HP 48G is a programmable calculator circa 1993.
x << DUP -/ 2 SWAP FOR F DUP IF F / DUP FP 0 =/= THEN DROP ELSE DUP ROT DUP ROT / SWAP END NEXT >>
Input value (x) is duplicated (DUP). The sqrt of 1 copy along with the value 2 delimit a for/next loop, (F) is the counter.
The input value (x) is divided by the counter (F), 2 through sqrt(x), and tested for remainder. If no remainder than that number is duplicated and one copy is used to find its �complimentary value� (the quotient of division of (x) by (F).
SWAP, DROP and ROT are stack manipulators. FP is fractional part.
The point of my program is to demonstrate that (relatively speaking) your not so, "I've just realised how deply sad I am", at all.
If anyone should be sad it�s me. My program requires several seconds to solve the value 1111111. Your program is in my favorites for as long as it is available.
I�m happy, (relatively speaking), so get over it!