Donate SIGN UP

prime numbers

Avatar Image
cavendish | 14:47 Tue 13th Dec 2005 | Science
7 Answers
Can anyone tell me if 1111111 is a prime number? Thanks!
Gravatar

Answers

1 to 7 of 7rss feed

Best Answer

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.

no


239 * 4649

I've just realised how deply sad I am : I've written (out of noseyness to see how long it would take me) a small prog that will test to see if a number is a prime or not.

Sad.

<< 1 1000 FOR F IF 1111111 F / DUP FP O == THEN 500 1 BEEP ELSE DROP END NEXT >> HP 48G


*v*

mine allows user input rather than always testing 1111111 ;-)

x << DUP -/ 2 SWAP FOR F DUP IF F / DUP FP 0 =/= THEN DROP ELSE DUP ROT DUP ROT / SWAP END NEXT >>


(-/) is sqrt sign. (=/=) not equal. HP48G program code.


Using no remainder test, returns greatest factors of x in order with compliments. *^*

I'm still not convinced.

(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!

1 to 7 of 7rss feed

Do you know the answer?

prime numbers

Answer Question >>