Congratulation! It’s essential that you don’t tell the algorithm, at least for now. You have an extra solution, where every horizontal has its equal vertical. Which is perfectly okay, but I wonder if that is the property of your algorithm?
I’m pretty sure arbitrarily large squares are possible. Here’s an argument that assumes primes behave like random numbers, which is often okay to assume. By the prime number theorem, the chance that an N-digit number is prime is proportional to 1/N. So the chance that N^2 random digits arranged in a square will form 2N primes (N rows and N columns) is about 1/N^(2N). But the number of ways to select N^2 digits is 10^(N^2) which easily overwhelms that.
The bottom and the rightmost prime can both have only odd digits without 5. The probability for each prime to fit there is then only (2/5)^N times that. We can’t see them as independent random numbers.
If you’re pointing out that my argument isn’t rigorous, I know. It can be overcome by some kind of non-random conspiracy among primes. But it needs to be a hell of a strong conspiracy, much stronger than what you mention. Even if the whole square had to consist of only 1 3 7 9, you’d still have 4^(N^2) possible squares, and 1/N^(2N) of them would still be a huge number.
Example, just for fun:
9 7 9 7 7 9 9 1
1 7 9 9 7 1 3 1
7 9 3 9 7 3 9 9
3 3 1 7 9 1 9 7
7 3 3 1 9 7 3 1
7 7 9 1 7 1 3 9
3 1 1 7 9 1 1 9
3 9 3 3 3 3 1 1
Heck, I can even make these:
1 1 1 9 1 9 9 1
9 1 1 1 1 1 9 9
1 9 1 9 9 1 1 9
1 1 1 1 1 9 1 1
1 9 1 1 9 9 1 1
9 1 9 1 1 1 1 9
9 9 1 1 9 1 9 1
1 9 1 9 9 1 1 9
Bottom line, primes are much more common than you think :-)
Here’s another fun argument. The question boils down to “how common are primes?” And the answer is, very common. We can define a subset of positive integers as “small” if the sum of their reciprocals converges, and “large” otherwise. For example, the set of all positive integers is large (because the harmonic series diverges), and the complement of any small set is large. Well, it’s possible to prove that the set of all primes is large, while the set of all numbers not containing some digit (say, 7) is small. So once you go far enough from zero, there are way more primes than there are numbers not containing 7. Now it doesn’t sound as surprising that you can make squares out of primes, does it?
Say, that we have N-1 lines, with N-1 primes. Each N digits. What we now need is an N digit prime number to put it below.
Its most significant digit may be 1, 3, 7 or 9. Otherwise, the leftmost vertical number wouldn’t be prime. If the sum of all N-1 other rightmost digits is X, then:
If X mod 3 = 0, then just 1 and 7 are possible, otherwise the leftmost vertical would be divisible by 3.
If X mod 3 = 1, then 1, 3, 7 and 9 are possible.
If X mod 3 = 2, then just 3 and 9 are possible, otherwise the leftmost vertical would be divisible by 3.
The probability is (1/3)*(((1+2+1)/5))=4/15 that the first digit fits. (4/15)^N, that all N digit fit.
Actually, we must consider the probability of divisibility by 11, which is roughly 1⁄11, which further reduces 4⁄15 per number to 40⁄165. And with 7 … and so on.
For the divisibility with 3, we render out not only one permutation of N-1 primes but all of them. For the divisibilty with 11, some of them.
It is indeed quite complicated. But if you handwavily estimate the results of all that complexity—the probabilities of divisibility by various things—then the estimate you get is the one cousin_it gave earlier, because the Prime Number Theorem is what you get when you estimate the density of prime numbers by treating divisibility-by-a-prime as a random event. (Which for many purposes works very well.)
There are 143 primes between 100 and 999. We can, therefore, make 2,924,207 3x3 different squares with 3 horizontal primes. 50,621 of them have all three vertical numbers prime. About 1.7%.
There are 1061 primes between 1000 and 9999. We can, therefore, make 1,267,247,769,841 4x4 different squares with 4 horizontal primes. 406,721,511 of them have all four vertical numbers prime. About 0.032%.
I strongly suspect that this goes to 0, quite rapidly.
How many Sudokus can you get with 9 digit primes horizontally and vertically?
Not a single one. Which is quite obvious when you consider that you can’t have a 2, 4, 6, or 8 in the bottom row. But you have to, to have a Sudoku, by the definition.
I’m sure you’re right that the fraction of all-horizontals-prime grids that have all verticals prime tends to 0 as the size increases. But the number of such grids increases rapidly too.
Interesting line of inferring… I am quite aware how dense primes are, but that might not be enough.
I have counted all these 4x4 (decimal) crossprimes. There are 913,425,530 of them if leading zeros are allowed. But only 406,721,511 without leading zeros.
if leading zeros ARE allowed, then there are certainly arbitrary large crossprimes out there. But if leading zeros aren’t allowed, I am not that sure. I have no proof, of course.
Congratulation! It’s essential that you don’t tell the algorithm, at least for now. You have an extra solution, where every horizontal has its equal vertical. Which is perfectly okay, but I wonder if that is the property of your algorithm?
No, it gives plenty of non-symmetric solutions as well. Here’s one:
Very well. What do you think, are there arbitrary large squares possible or not?
I think not. Even in binary notations NxN and above, probably don’t exist for an N, large enough.
I’m pretty sure arbitrarily large squares are possible. Here’s an argument that assumes primes behave like random numbers, which is often okay to assume. By the prime number theorem, the chance that an N-digit number is prime is proportional to 1/N. So the chance that N^2 random digits arranged in a square will form 2N primes (N rows and N columns) is about 1/N^(2N). But the number of ways to select N^2 digits is 10^(N^2) which easily overwhelms that.
The bottom and the rightmost prime can both have only odd digits without 5. The probability for each prime to fit there is then only (2/5)^N times that. We can’t see them as independent random numbers.
If you’re pointing out that my argument isn’t rigorous, I know. It can be overcome by some kind of non-random conspiracy among primes. But it needs to be a hell of a strong conspiracy, much stronger than what you mention. Even if the whole square had to consist of only 1 3 7 9, you’d still have 4^(N^2) possible squares, and 1/N^(2N) of them would still be a huge number.
Example, just for fun:
Heck, I can even make these:
Bottom line, primes are much more common than you think :-)
Here’s another fun argument. The question boils down to “how common are primes?” And the answer is, very common. We can define a subset of positive integers as “small” if the sum of their reciprocals converges, and “large” otherwise. For example, the set of all positive integers is large (because the harmonic series diverges), and the complement of any small set is large. Well, it’s possible to prove that the set of all primes is large, while the set of all numbers not containing some digit (say, 7) is small. So once you go far enough from zero, there are way more primes than there are numbers not containing 7. Now it doesn’t sound as surprising that you can make squares out of primes, does it?
Say, that we have N-1 lines, with N-1 primes. Each N digits. What we now need is an N digit prime number to put it below.
Its most significant digit may be 1, 3, 7 or 9. Otherwise, the leftmost vertical number wouldn’t be prime. If the sum of all N-1 other rightmost digits is X, then:
If X mod 3 = 0, then just 1 and 7 are possible, otherwise the leftmost vertical would be divisible by 3. If X mod 3 = 1, then 1, 3, 7 and 9 are possible. If X mod 3 = 2, then just 3 and 9 are possible, otherwise the leftmost vertical would be divisible by 3.
The probability is (1/3)*(((1+2+1)/5))=4/15 that the first digit fits. (4/15)^N, that all N digit fit.
Actually, we must consider the probability of divisibility by 11, which is roughly 1⁄11, which further reduces 4⁄15 per number to 40⁄165. And with 7 … and so on.
For the divisibility with 3, we render out not only one permutation of N-1 primes but all of them. For the divisibilty with 11, some of them.
It’s quite complicated.
It is indeed quite complicated. But if you handwavily estimate the results of all that complexity—the probabilities of divisibility by various things—then the estimate you get is the one cousin_it gave earlier, because the Prime Number Theorem is what you get when you estimate the density of prime numbers by treating divisibility-by-a-prime as a random event. (Which for many purposes works very well.)
There are 143 primes between 100 and 999. We can, therefore, make 2,924,207 3x3 different squares with 3 horizontal primes. 50,621 of them have all three vertical numbers prime. About 1.7%.
There are 1061 primes between 1000 and 9999. We can, therefore, make 1,267,247,769,841 4x4 different squares with 4 horizontal primes. 406,721,511 of them have all four vertical numbers prime. About 0.032%.
I strongly suspect that this goes to 0, quite rapidly.
How many Sudokus can you get with 9 digit primes horizontally and vertically?
Not a single one. Which is quite obvious when you consider that you can’t have a 2, 4, 6, or 8 in the bottom row. But you have to, to have a Sudoku, by the definition.
It’s a bit analogous situation here.
I’m sure you’re right that the fraction of all-horizontals-prime grids that have all verticals prime tends to 0 as the size increases. But the number of such grids increases rapidly too.
Interesting line of inferring… I am quite aware how dense primes are, but that might not be enough.
I have counted all these 4x4 (decimal) crossprimes. There are 913,425,530 of them if leading zeros are allowed. But only 406,721,511 without leading zeros.
if leading zeros ARE allowed, then there are certainly arbitrary large crossprimes out there. But if leading zeros aren’t allowed, I am not that sure. I have no proof, of course.
This one is also attractive in that primes are not repeated.