Investigating a Function which Mimics Prime Numbers

In summary, the function f(n) returns prime number n, only with a few false positives thrown in between.
  • #1
kenewbie
239
0
I was playing around trying to find a function which matches the prime numbers (futile, I know) when I stumbled upon this little thing:

f(n) = n^2 - (n-1)^2 (for n>1, it seems)

which gives

f(2) = 3
f(3) = 5
f(4) = 7
f(5) = 9 (off by -2)
f(6) = 11
f(7) = 13
f(8) = 15 (-2)
f(9) = 17
f(10) = 19

and so on. I only verified this up to n = 32 (at which point you get 32^2 = 1024 and the numbers become cumbersome to work with by hand, for me at least), but it seems like the function f(n) returns prime number n, only with a few false positives thrown in between (at -2 or -4 off).

At least it does not seem to skip any primes :)

I cannot seem to get any obvious patters within the false positives. The gap seem to vary, it is not the case that the function is off only when n itself is prime, and so on. The only thing i can see that the first 32 n implies is that if f(n) is off by -4 then f(n+1) is off by -2 and then f(n+2) = Pn. (well, not Pn, but the next P after f(n-1) at least).

Now I understand that such a simple function which seems so close to the primes must have been extensively studied, so I wondered if anyone knew of any interesting properties here, or perhaps a paper or a book or something.

k

Code:
edit: included below is the table for as far as I went with it, leading zero for readability.

f(02) = 004 - 001 = 3
f(03) = 009 - 004 = 5
f(04) = 016 - 009 = 7
f(05) = 025 - 016 = 9  (-2)
f(06) = 036 - 025 = 11
f(07) = 049 - 036 = 13
f(08) = 064 - 049 = 15 (-2)
f(09) = 081 - 064 = 17
f(10) = 100 - 081 = 19
f(11) = 121 - 100 = 21 (-2)
f(12) = 144 - 121 = 23
f(13) = 169 - 144 = 25 (-4)
f(14) = 196 - 169 = 27 (-2)
f(15) = 225 - 196 = 29
f(16) = 256 - 225 = 31
f(17) = 289 - 256 = 33 (-4)
f(18) = 324 - 289 = 35 (-2)
f(19) = 361 - 324 = 37
f(20) = 400 - 361 = 39 (-2)
f(21) = 441 - 400 = 41
f(22) = 484 - 441 = 43
f(23) = 529 - 484 = 45 (-2)
f(24) = 576 - 529 = 47
f(25) = 625 - 576 = 49 (-4)
f(26) = 676 - 625 = 51 (-2)
f(27) = 729 - 676 = 53
f(28) = 784 - 729 = 55 (-4)
f(29) = 841 - 784 = 57 (-2)
f(30) = 900 - 841 = 59 
f(31) = 961 - 900 = 61
 
Last edited:
Physics news on Phys.org
  • #2
If you simplify your function:
f(n) = n^2 - (n-1)^2 = n^2 - ( n^2 - 2n + 1) = 2n - 1
You can see that it produces all the odd numbers. So, your function will produce all the primes (except for 2) and it will give you many false positives since not every odd number is prime.
 
  • #3
Ouch!

Thanks a lot. I feel like I should have seen that myself, but alas :)

k
 

Related to Investigating a Function which Mimics Prime Numbers

1. What is a function that mimics prime numbers?

A function that mimics prime numbers is a mathematical expression that generates a sequence of numbers that behave similarly to prime numbers. This means that the numbers in the sequence can only be divided by 1 and itself without resulting in a remainder.

2. How can a function mimic prime numbers?

A function can mimic prime numbers by using specific mathematical operations and patterns to generate a sequence of numbers that have similar properties to prime numbers. These operations and patterns can be used to determine if a number is prime or not, just like with actual prime numbers.

3. What are the characteristics of a function that mimics prime numbers?

The characteristics of a function that mimics prime numbers include generating a sequence of numbers that can only be divided by 1 and itself without resulting in a remainder, having a consistent pattern of increasing or decreasing values, and following certain mathematical rules or formulas.

4. How are these functions useful in mathematics?

Functions that mimic prime numbers are useful in mathematics as they can help identify patterns and relationships between numbers. They can also be used in cryptography and number theory, as well as in the study of complex mathematical systems and structures.

5. Can a function that mimics prime numbers generate an infinite sequence?

Yes, a function that mimics prime numbers can generate an infinite sequence of numbers. Just like prime numbers, these functions can continue to generate new numbers without reaching an end point, as long as the operation and pattern used in the function remain consistent.

Similar threads

Replies
10
Views
1K
  • Linear and Abstract Algebra
Replies
6
Views
3K
  • General Math
Replies
2
Views
1K
  • Linear and Abstract Algebra
Replies
2
Views
2K
  • Linear and Abstract Algebra
Replies
1
Views
3K
  • Linear and Abstract Algebra
Replies
2
Views
2K
Replies
1
Views
2K
  • Linear and Abstract Algebra
Replies
1
Views
3K
  • Precalculus Mathematics Homework Help
Replies
1
Views
1K
  • Math Proof Training and Practice
Replies
33
Views
7K
Back
Top