lainchan / r
Prime numbers
Unsigned · 2025-11-05 16:59
Guys, I think I found a pattern in prime numbers. How do I check if it's something known already or if I discovered somethig new?
>INB4 elaborate
I don't have time to elaborate right now, I'll elaborate at Friday.
Splicer · 2025-11-05 17:37
Check this, for starters:
https://chatgpt.com/s/t_690bfb4834a48191acf12acce9e92a06
Yamaoto Toshi · 2025-11-05 17:45
>>47612
>>47613
you have chatgpt cyberpsychosis
stop talking to AI
Delilah · 2025-11-06 03:04
Okay, false alarm. It only seems to work for small numbers because so many of the odd numbers are prime, but it doesn't work for bigger numbers. Forget that I said anything.
Yet Another Lainon · 2025-11-06 04:41
>>47613
All of these are well-known patterns that you definitely haven't "found". In fact, all of what ChatGPT spewed out is just introduction to number theory
Acid Burn · 2025-11-06 08:15
>>47613
Thanks anon. I'll look into it.
I have been experimenting with formula
prime + 2 ^ x
For example
29 + 2 ^3 = 37
It doesn't always generate primes, but sometimes it does.
Here's a little script to calculate it:
var lp = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397 ];
var c = 0;
var cc = 1;
var ccco = 20;
var test = lp[c];
var res = 0;
while(c<lp.length) {
while(cc<ccco) {
res = test + Math.pow(2,cc);
console.log(test + " + 2 ^" + cc + " = " + res);
cc++;
}
cc = 1;
c++;
test = lp[c];
}
Nemissa · 2025-11-06 08:50
>>47619
I'd say, if you can come up with something that does generate primes most of the time conveniently, it's quite useful. Because primes are often useful as utility inside of unrelated applications.
Just another Random Lainon · 2025-11-06 08:52
Now if you take the prime that you put into the equation and multiply it by the prime that is the result of the equation, you'll get a number and if you do a square root of that number, you'll get a number that is somewhat between that two primes.
For example:
37 + 16 = 53
37 * 53 = 1961
square root of 1961 is about 44 which is between 37 and 53
Unspecified · 2025-11-06 10:06
>>47620
I don't know what you want to use them for but usually Sieve of Eratosthenes is enough.
If properly written you can achieve computational complexity of x^1.5 and allocating memory only for the primes (not all [2,x]).
In Pyhon I managed to get to 10_000_000 in ~30s.
Since primes never change you can save those values to a file and have a "head start".
If user wants less than your max value computational complexity should be x^0.5. If he wants more you have a head start of the values from inside the file. Than you can update the file again and again.
It's not good way of looking for new primes because you will get slow checking if a candidate is divisible by each discovered prime (up to sqrt(candidate), there is no reason to go higher)
I thought about using an alternative method to filter out potential candidates faster but over time I would end with slower results, mistake I made was removing values directly from list instead of adding valid values to new list and re-indexing killed the algorithm.
Example:
We check for 2 and 3 manually.
period = 2*3 = 6
[5, 6, 7, 8, 9, 10] - we allocate a list in size of our period (we start with max(2, 3)+2 to be a bit faster)
We remove values divisible by 2 or 3 (making a new list with valid candidates should be more efficient)
candidates = [5, 7]
We iterate over candidates and compare with already found primes, after every check we add our period. Do not remove if a candidate is not a prime, we remove only initially.
candidates = [5, 7], primes = [2, 3]
candidates = [5+6=11, 7], primes = [2, 3, 5]
candidates = [11, 7+6=13], primes = [2, 3, 5, 7]
...
candidates = [29, 25], primes = [2, 3, 5, 7, 11, 13, 17, 19, 23]
We just ignore 25 and add period to it continuing our iterations.
candidates = [29, 31], primes = [2, 3, 5, 7, 11, 13, 17, 19, 23]
etc.
Removing even numbers removes 50% of candidates. Removing divisible by 2 and 3 removes 67%. We get diminishing returns with each additional number. For 2, 3 and 5 we skip only 73%.
Example of 2, 3 and 5
period = 2*3*5 = 30
candidates = [7, 8, 9, ..., 34, 35, 36]
after removing divisible by 2, 3 or 5
candidates = [7, 11, 13, 17, 19, 23, 29, 31]
iterations:
candidates = [7, 11, 13, 17, 19, 23, 29, 31], primes = [2, 3, 5]
candidates = [37, 11, 13, 17, 19, 23, 29, 31], primes = [2, 3, 5, 7]
candidates = [37, 41, 13, 17, 19, 23, 29, 31], primes = [2, 3, 5, 7, 11]
...
candidates = [37, 41, 43, 47, 49, 53, 59, 61], primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]
candidates = [67, 41, 43, 47, 49, 53, 59, 61], primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]
Generally the most efficient way I found is to have them ready in some file, but we have to put them there somehow.
Ein · 2025-11-06 14:24
>>47623
But I want to find something new. Some new direction to make it even more efficient.
Check this out:
41 * 151 = 6191
√6191 = 78
Now if you substract a prime number 37 or add prime number 73 you get the prime numbers 41 and 151 back.
41 <-- 37 --< 78 >-- 73 --> 151
So the square root of 6191 is two prime numbers away from its prime number roots.
Isn't that crazy?
It works for other prime numbers as well:
211 * 223 = 47053
√47053 = 216
211 <-- 5 --< 216 >-- 7 --> 223
I'm going to write a script that checks these unusual cases where a square root of a product of two prime numbers is two prime numbers away from other prime numbers (its roots).
Isn't that interesting?
XERXES · 2025-11-06 15:46
>>47633
I don't really understand:
You take 2 completely random primes. (?)
Multiply them and square root them.
Round to the nearest integer.
Subtract one of the original primes or subtract from it.
2 new primes as a result?
So if we take
41 * 151 = 6191
√6191 = 78
78 - 41 = 37, 151 - 78 = 73
37 * 73 = 2701
√2701 = 52
52 - 37 = 15(?), 73 - 52 = 21(?)
???
Lord Nikon · 2025-11-07 01:06
The interesting thing about primes is that they *don't* appear to be random. They have tons of patterns, but at the same time, generating them is quite slow.
You should look up the Mier-Rabin test, it almost feels magical.
J.C. Denton · 2025-11-07 01:27
>>47621
Just my 2 cents
This property holds true for any 2 natural numbers, where one is greater than the other.
This is because if you square the greater, you will overshoot, and if you square the lesser, you will undershoot.
A more rigorous proof:
Let n and m be 2 natural numbers, where m > n
Let x be the product of the two (x = n X m)
Clearly,
n X n < x < m X m
Taking the square root,
n < root(x) < m
QED.
Ivan Horvat · 2025-11-07 08:14
>>47636
> 78 - 41 = 37, 151 - 78 = 73
No.
78 - 37 = 41
78 + 73 = 151
Delilah · 2025-11-08 02:51
Check this out. You cannot tell me this is a coincidence.
William Holtzer · 2025-11-08 05:21
>>47651
The only thing I am getting from this is that you multiplied numbers and got some result.
Care to elaborate?
Vasya Pupkin · 2025-11-08 09:32
>>47654
Isn't the image self evident?
Start with a square grid. Draw a 45° diagonal line. Draw it so it crosses a prime number of squares. (I don't want to say that the length is a prime number, because to get the true length you would need to use the Pythagorean theorem, but the true length is irrelevant, we only care about how many squares it crosses - you could say that its "pseudo-length" is 31.)
Now draw a prime number of lines of the same length right next to it. (In this case 23 lines.) Then fill shorter lines next to them to make it into a rectangle. Then if you check the length of the sides of the rectangle, one of them will be the same the prime you started with (in this case 31), but the other one will be a new prime (in this case 53). I mean not always, but often it is.
Debbie Charteris · 2025-11-08 10:02
>>47657
Nothing in your method is self evident.
>I mean not always, but often it is.
Define often. How good of a method is this.
I will give it to you if it can generate all primes and it finds them "often" enough it's valid but proof requires more than an example.
31 on first grid should be at the bottom like it's on last grid to indicate it's 31 squares, not length.
I would also remove * from *23, I was confused how that function got multiplied by 23 where you clearly added 23 to original.
From what you present I see prime1 + prime2 +(1 OR 0 OR -1) = candidate. And I'm pretty sure it's not that novel idea.
Lunch · 2025-11-08 13:10
>>47651
awww, ulam spiral transposed to new grid :3 good for you anon!