Qbasicnews.com July 02, 2020, 07:06:52 AM  Pages: Author Topic: Primed and Ready  (Read 3541 times)
whodat
Member Posts: 31 « on: October 14, 2005, 11:41:24 AM »

How many prime numbers can you find that are 1 less than a perfect square? Logged
Antoni Gual
Na_th_an     Posts: 1434   « Reply #1 on: October 14, 2005, 04:16:50 PM »

Funny challenge!
If  Mr Caldwell does enter you're lost..... :wink: Logged

Antoni
rpgfan3233
Ancient Guru    Posts: 617  « Reply #2 on: October 14, 2005, 04:32:13 PM »

I have the answer, without much time spent either: there can be only one.
4 (perfect square) - 1 = 3 (prime)
9 (perfect square) - 1 = 8 (not prime)
16 (perfect square) - 1 = 15 (not prime)
25 (perfect square) - 1 = 24 (not prime)
36 (perfect square) - 1 = 35 (not prime)
49 (perfect square) - 1 = 48 (not prime)
64 (perfect square) - 1 = 63 (not prime)

Do you see a pattern here? The results increment like this:
a(n) = a(n-1) + (a(n-1) - a(n-2)) + 2
This means that the current result is found by adding to the difference between the previous two results. In other words:
8 + (8 - 3) + 2 = 8 + (5) + 2 = 15
15 + (15 - + 2 = 15 + (7) + 2 = 24
24 + (24 - 15) + 2 = 24 + (9) + 2 = 35

Note the increments shown in parentheses. They have a difference of 2 (because of the +2 at the end).

A little math lesson for people who hate it.

Because this keeps happening (and rendering non-prime numbers), the only possible prime number that fits your criterion is the number 3. Logged

974277320612072617420666C61696C21 (Hexadecimal for those who don't know)
whodat
Member Posts: 31 « Reply #3 on: October 14, 2005, 04:39:56 PM »

Quote from: "Antoni Gual"
Funny challenge!
If  Mr Caldwell does enter you're lost..... :wink:

I don't know Mr. Caldwell, but you had better post your code before he beats you to it!  Logged
whodat
Member Posts: 31 « Reply #4 on: October 14, 2005, 04:48:12 PM »

Quote from: "rpgfan3233"
I have the answer, without much time spent either: there can be only one.
4 (perfect square) - 1 = 3 (prime)
9 (perfect square) - 1 = 8 (not prime)
16 (perfect square) - 1 = 15 (not prime)
25 (perfect square) - 1 = 24 (not prime)
36 (perfect square) - 1 = 35 (not prime)
49 (perfect square) - 1 = 48 (not prime)
64 (perfect square) - 1 = 63 (not prime)

Do you see a pattern here? The results increment like this:
a(n) = a(n-1) + (a(n-1) - a(n-2)) + 2
This means that the current result is found by adding to the difference between the previous two results. In other words:
8 + (8 - 3) + 2 = 8 + (5) + 2 = 15
15 + (15 - + 2 = 15 + (7) + 2 = 24
24 + (24 - 15) + 2 = 24 + (9) + 2 = 35

Note the increments shown in parentheses. They have a difference of 2 (because of the +2 at the end).

A little math lesson for people who hate it.

Because this keeps happening (and rendering non-prime numbers), the only possible prime number that fits your criterion is the number 3.

It can be made even simpler:  Your looking for a prime number of the form N^2 -1.  This can always be factored into (N+1)*(N-1).
In the case where N=2, one of the factors is 1, the other one happens to be prime (3).

I was hoping someone would start writing code, but no one bit.
:bounce: Logged
Antoni Gual
Na_th_an     Posts: 1434   « Reply #5 on: October 14, 2005, 05:50:44 PM »

Mr Caldwell runs the Prime Page http://primes.utm.edu/
You can find there 3 is the only prime that fits the criterion.
I modified some code to do the search, but as it did'nt find anything,  I checked the Prime Page....
I would give the prize to rpgfan, who actually thinked at the problem.... Logged

Antoni
rpgfan3233
Ancient Guru    Posts: 617  « Reply #6 on: October 14, 2005, 07:08:47 PM »

Quote from: "Antoni Gual"
I would give the prize to rpgfan, who actually thinked at the problem....

No, I'm just a maths geek. Prime numbers seem to be a topic for discussion within the QB community right now. Logged

974277320612072617420666C61696C21 (Hexadecimal for those who don't know)
 Pages: