PrimeGrid
Please visit donation page to help the project cover running costs for this month

Toggle Menu

Join PrimeGrid

Returning Participants

Community

Leader Boards

Results

Other

drummers-lowrise

Advanced search

Message boards : General discussion : Get prime from concatenating first n numbers

Author Message
Profile JeppeSNProject donor
Avatar
Send message
Joined: 5 Apr 14
Posts: 1695
ID: 306875
Credit: 40,801,467
RAC: 11,879
Found 1 prime in the 2020 Tour de Primes321 LLR Gold: Earned 500,000 credits (593,283)Cullen LLR Gold: Earned 500,000 credits (611,298)ESP LLR Silver: Earned 100,000 credits (174,818)Generalized Cullen/Woodall LLR Silver: Earned 100,000 credits (112,799)PPS LLR Jade: Earned 10,000,000 credits (15,960,183)PSP LLR Silver: Earned 100,000 credits (428,457)SoB LLR Silver: Earned 100,000 credits (466,812)SR5 LLR Silver: Earned 100,000 credits (210,142)SGS LLR Silver: Earned 100,000 credits (112,277)TRP LLR Silver: Earned 100,000 credits (342,501)Woodall LLR Silver: Earned 100,000 credits (109,455)321 Sieve (suspended) Silver: Earned 100,000 credits (175,037)PPS Sieve Bronze: Earned 10,000 credits (10,113)AP 26/27 Bronze: Earned 10,000 credits (12,129)GFN Ruby: Earned 2,000,000 credits (4,228,147)WW Turquoise: Earned 5,000,000 credits (9,640,000)PSA Turquoise: Earned 5,000,000 credits (7,614,290)
Message 152676 - Posted: 15 Dec 2021 | 16:24:21 UTC

Numberphile's newest video is The Most Wanted Prime Number, featuring N. J. A. Sloane from the OEIS.

They want to find a prime number by concatenating the (decimal) representations of 1, 2, 3, ..., n. You can search in PARI/GP like this:

b=10;N=1;for(n=2,+oo,N=N*b^(1+logint(n,b))+n;ispseudoprime(N)&&print(n))


If you change the first part to other bases, like b=12, you find examples.

/JeppeSN

Profile JeppeSNProject donor
Avatar
Send message
Joined: 5 Apr 14
Posts: 1695
ID: 306875
Credit: 40,801,467
RAC: 11,879
Found 1 prime in the 2020 Tour de Primes321 LLR Gold: Earned 500,000 credits (593,283)Cullen LLR Gold: Earned 500,000 credits (611,298)ESP LLR Silver: Earned 100,000 credits (174,818)Generalized Cullen/Woodall LLR Silver: Earned 100,000 credits (112,799)PPS LLR Jade: Earned 10,000,000 credits (15,960,183)PSP LLR Silver: Earned 100,000 credits (428,457)SoB LLR Silver: Earned 100,000 credits (466,812)SR5 LLR Silver: Earned 100,000 credits (210,142)SGS LLR Silver: Earned 100,000 credits (112,277)TRP LLR Silver: Earned 100,000 credits (342,501)Woodall LLR Silver: Earned 100,000 credits (109,455)321 Sieve (suspended) Silver: Earned 100,000 credits (175,037)PPS Sieve Bronze: Earned 10,000 credits (10,113)AP 26/27 Bronze: Earned 10,000 credits (12,129)GFN Ruby: Earned 2,000,000 credits (4,228,147)WW Turquoise: Earned 5,000,000 credits (9,640,000)PSA Turquoise: Earned 5,000,000 credits (7,614,290)
Message 152677 - Posted: 15 Dec 2021 | 16:36:30 UTC

I see that:

82 81 80 79 78 ... 11 10 9 8 7 6 5 4 3 2 1

is a prime number.

/JeppeSN

Profile Eudy SilvaProject donor
Avatar
Send message
Joined: 26 Aug 17
Posts: 1842
ID: 918937
Credit: 422,349,106
RAC: 338,894
Discovered 2 mega primesFound 2 primes in the 2018 Tour de PrimesFound 1 prime in the 2019 Tour de PrimesFound 1 prime in the 2020 Tour de PrimesFound 1 prime in the 2021 Tour de Primes321 LLR Amethyst: Earned 1,000,000 credits (1,187,213)Cullen LLR Amethyst: Earned 1,000,000 credits (1,291,013)ESP LLR Amethyst: Earned 1,000,000 credits (1,151,976)Generalized Cullen/Woodall LLR Amethyst: Earned 1,000,000 credits (1,199,207)PPS LLR Sapphire: Earned 20,000,000 credits (26,223,152)PSP LLR Amethyst: Earned 1,000,000 credits (1,476,639)SoB LLR Ruby: Earned 2,000,000 credits (2,432,091)SR5 LLR Ruby: Earned 2,000,000 credits (3,137,603)SGS LLR Amethyst: Earned 1,000,000 credits (1,462,951)TRP LLR Amethyst: Earned 1,000,000 credits (1,574,163)Woodall LLR Amethyst: Earned 1,000,000 credits (1,001,901)321 Sieve (suspended) Amethyst: Earned 1,000,000 credits (1,119,749)Generalized Cullen/Woodall Sieve (suspended) Amethyst: Earned 1,000,000 credits (1,005,331)PPS Sieve Emerald: Earned 50,000,000 credits (75,311,511)AP 26/27 Emerald: Earned 50,000,000 credits (91,719,498)GFN Double Bronze: Earned 100,000,000 credits (104,992,890)WW Double Bronze: Earned 100,000,000 credits (104,012,000)PSA Ruby: Earned 2,000,000 credits (2,059,222)
Message 152678 - Posted: 15 Dec 2021 | 17:09:41 UTC - in response to Message 152676.

Numberphile's newest video is The Most Wanted Prime Number, featuring N. J. A. Sloane from the OEIS.

They want to find a prime number by concatenating the (decimal) representations of 1, 2, 3, ..., n. You can search in PARI/GP like this:
b=10;N=1;for(n=2,+oo,N=N*b^(1+logint(n,b))+n;ispseudoprime(N)&&print(n))


If you change the first part to other bases, like b=12, you find examples.

/JeppeSN

Nice !
____________

"Accidit in puncto, quod non contingit in anno."
Something that does not occur in a year may, perchance, happen in a moment.

Profile JeppeSNProject donor
Avatar
Send message
Joined: 5 Apr 14
Posts: 1695
ID: 306875
Credit: 40,801,467
RAC: 11,879
Found 1 prime in the 2020 Tour de Primes321 LLR Gold: Earned 500,000 credits (593,283)Cullen LLR Gold: Earned 500,000 credits (611,298)ESP LLR Silver: Earned 100,000 credits (174,818)Generalized Cullen/Woodall LLR Silver: Earned 100,000 credits (112,799)PPS LLR Jade: Earned 10,000,000 credits (15,960,183)PSP LLR Silver: Earned 100,000 credits (428,457)SoB LLR Silver: Earned 100,000 credits (466,812)SR5 LLR Silver: Earned 100,000 credits (210,142)SGS LLR Silver: Earned 100,000 credits (112,277)TRP LLR Silver: Earned 100,000 credits (342,501)Woodall LLR Silver: Earned 100,000 credits (109,455)321 Sieve (suspended) Silver: Earned 100,000 credits (175,037)PPS Sieve Bronze: Earned 10,000 credits (10,113)AP 26/27 Bronze: Earned 10,000 credits (12,129)GFN Ruby: Earned 2,000,000 credits (4,228,147)WW Turquoise: Earned 5,000,000 credits (9,640,000)PSA Turquoise: Earned 5,000,000 credits (7,614,290)
Message 152680 - Posted: 15 Dec 2021 | 17:36:02 UTC

Turns out 82 is followed by 37765; see A176024. Also see Mersenneforum thread Smarandache prime(s). /JeppeSN

Profile BurProject donor
Volunteer tester
Avatar
Send message
Joined: 25 Feb 20
Posts: 511
ID: 1241833
Credit: 407,815,873
RAC: 10,359
321 LLR Ruby: Earned 2,000,000 credits (2,092,823)Cullen LLR Ruby: Earned 2,000,000 credits (2,315,295)ESP LLR Ruby: Earned 2,000,000 credits (2,151,088)Generalized Cullen/Woodall LLR Ruby: Earned 2,000,000 credits (2,620,968)PPS LLR Jade: Earned 10,000,000 credits (10,943,107)PSP LLR Ruby: Earned 2,000,000 credits (2,064,832)SoB LLR Ruby: Earned 2,000,000 credits (2,434,466)SR5 LLR Ruby: Earned 2,000,000 credits (2,065,004)SGS LLR Ruby: Earned 2,000,000 credits (2,027,649)TRP LLR Ruby: Earned 2,000,000 credits (2,089,856)Woodall LLR Ruby: Earned 2,000,000 credits (2,112,258)321 Sieve (suspended) Ruby: Earned 2,000,000 credits (2,107,153)PPS Sieve Turquoise: Earned 5,000,000 credits (5,096,952)AP 26/27 Turquoise: Earned 5,000,000 credits (5,797,662)GFN Jade: Earned 10,000,000 credits (10,874,159)WW Double Silver: Earned 200,000,000 credits (349,980,000)PSA Amethyst: Earned 1,000,000 credits (1,042,601)
Message 152773 - Posted: 22 Dec 2021 | 18:03:44 UTC - in response to Message 152680.
Last modified: 22 Dec 2021 | 18:06:59 UTC

Jeppe, I tried the same, but my code for creating the number is a bit more complicated... :)

m=2000;p=0;k=0;for (i=1,m,k+=ceil(log(i)/log(10));p+=i*10^k;if(ispseudoprime(p),print("Prime: ",p)))



And the other suggested format of increasing and then decreasing values like 12345678910987654321:

updown(r,s) = {
b=s;
for(a=r,s-1,
p=0;k=0;for (i=a,b,p+=i*10^k;k+=(floor(log(i)/log(10))+1));
q=0;k=0;for (i=1,b-a,j=b-i;q+=j*10^k;k+=(floor(log(j)/log(10))+1));
p+=q*10^(floor(log(p)/log(10))+1);
\\ print(p);
if(ispseudoprime(p),print("yay: ",p," is prime!"))
)
}

And to run it: for(i=2,100,updown(1,i)) tests all number with 2 ... 100 in the middle and beginning at 1 to the middle value. Such as 121, 232, 12321, 343, 23432, 1234321, ...

Your slim code could be used there as well though. I got to understand what's going on there at first though.
____________
1281979 * 2^485014 + 1 is prime ... no further hits up to: n = 5,700,000

Profile JeppeSNProject donor
Avatar
Send message
Joined: 5 Apr 14
Posts: 1695
ID: 306875
Credit: 40,801,467
RAC: 11,879
Found 1 prime in the 2020 Tour de Primes321 LLR Gold: Earned 500,000 credits (593,283)Cullen LLR Gold: Earned 500,000 credits (611,298)ESP LLR Silver: Earned 100,000 credits (174,818)Generalized Cullen/Woodall LLR Silver: Earned 100,000 credits (112,799)PPS LLR Jade: Earned 10,000,000 credits (15,960,183)PSP LLR Silver: Earned 100,000 credits (428,457)SoB LLR Silver: Earned 100,000 credits (466,812)SR5 LLR Silver: Earned 100,000 credits (210,142)SGS LLR Silver: Earned 100,000 credits (112,277)TRP LLR Silver: Earned 100,000 credits (342,501)Woodall LLR Silver: Earned 100,000 credits (109,455)321 Sieve (suspended) Silver: Earned 100,000 credits (175,037)PPS Sieve Bronze: Earned 10,000 credits (10,113)AP 26/27 Bronze: Earned 10,000 credits (12,129)GFN Ruby: Earned 2,000,000 credits (4,228,147)WW Turquoise: Earned 5,000,000 credits (9,640,000)PSA Turquoise: Earned 5,000,000 credits (7,614,290)
Message 152775 - Posted: 22 Dec 2021 | 19:32:45 UTC

Where you say ceil(log(i)/log(10)), you can use 1+logint(i, 10) instead. Otherwise, it is more or less the same.

The good thing about logint (integer logarithm) is, it does not go through floating-point. It simply finds the "integer logarithm" of i, to base 10. You do not have to care about the value of the default realprecision.

Oh, and then I (ab)use the short-circuiting behavior of &&. So instead of:

if(b, something())

you can say:

b && something()

/JeppeSN

Profile BurProject donor
Volunteer tester
Avatar
Send message
Joined: 25 Feb 20
Posts: 511
ID: 1241833
Credit: 407,815,873
RAC: 10,359
321 LLR Ruby: Earned 2,000,000 credits (2,092,823)Cullen LLR Ruby: Earned 2,000,000 credits (2,315,295)ESP LLR Ruby: Earned 2,000,000 credits (2,151,088)Generalized Cullen/Woodall LLR Ruby: Earned 2,000,000 credits (2,620,968)PPS LLR Jade: Earned 10,000,000 credits (10,943,107)PSP LLR Ruby: Earned 2,000,000 credits (2,064,832)SoB LLR Ruby: Earned 2,000,000 credits (2,434,466)SR5 LLR Ruby: Earned 2,000,000 credits (2,065,004)SGS LLR Ruby: Earned 2,000,000 credits (2,027,649)TRP LLR Ruby: Earned 2,000,000 credits (2,089,856)Woodall LLR Ruby: Earned 2,000,000 credits (2,112,258)321 Sieve (suspended) Ruby: Earned 2,000,000 credits (2,107,153)PPS Sieve Turquoise: Earned 5,000,000 credits (5,096,952)AP 26/27 Turquoise: Earned 5,000,000 credits (5,797,662)GFN Jade: Earned 10,000,000 credits (10,874,159)WW Double Silver: Earned 200,000,000 credits (349,980,000)PSA Amethyst: Earned 1,000,000 credits (1,042,601)
Message 152778 - Posted: 23 Dec 2021 | 14:29:38 UTC - in response to Message 152775.
Last modified: 23 Dec 2021 | 14:31:15 UTC

Ah, I had read ?logint but didn't see why it could be used at first.

So the output of logint(a,b) is always identical to floor(log_b(a)) it just saves computing time by not going through the actual calculation of the log?

Interesting take on the & instead of if. Now I realized I actually used that a couple of times before just not in such simple constructs but only within an if clause to indicate progress by throwing an &!(print(...)) in there. Btw, is it convention that print(a) returns 0 upon successfully printing?
____________
1281979 * 2^485014 + 1 is prime ... no further hits up to: n = 5,700,000

Profile JeppeSNProject donor
Avatar
Send message
Joined: 5 Apr 14
Posts: 1695
ID: 306875
Credit: 40,801,467
RAC: 11,879
Found 1 prime in the 2020 Tour de Primes321 LLR Gold: Earned 500,000 credits (593,283)Cullen LLR Gold: Earned 500,000 credits (611,298)ESP LLR Silver: Earned 100,000 credits (174,818)Generalized Cullen/Woodall LLR Silver: Earned 100,000 credits (112,799)PPS LLR Jade: Earned 10,000,000 credits (15,960,183)PSP LLR Silver: Earned 100,000 credits (428,457)SoB LLR Silver: Earned 100,000 credits (466,812)SR5 LLR Silver: Earned 100,000 credits (210,142)SGS LLR Silver: Earned 100,000 credits (112,277)TRP LLR Silver: Earned 100,000 credits (342,501)Woodall LLR Silver: Earned 100,000 credits (109,455)321 Sieve (suspended) Silver: Earned 100,000 credits (175,037)PPS Sieve Bronze: Earned 10,000 credits (10,113)AP 26/27 Bronze: Earned 10,000 credits (12,129)GFN Ruby: Earned 2,000,000 credits (4,228,147)WW Turquoise: Earned 5,000,000 credits (9,640,000)PSA Turquoise: Earned 5,000,000 credits (7,614,290)
Message 152781 - Posted: 23 Dec 2021 | 19:31:34 UTC - in response to Message 152778.

Btw, is it convention that print(a) returns 0 upon successfully printing?


Yes, in PARI/GP, a "procedure" is a function which does not return anything (or returns the special void object, according to the user's manual). But this void thing will become a zero if you pick it up. For example:

print("hello") -print("hello") a=print("hello")

In the first example, the return value is void and is suppressed (not seen). In the second example, we force the use of void by negating it, and it becomes zero. This is like the 1&&print("hello") you ask for. In the third example above, again we get zero, this time stored in the variable a.

If in your home-made function, it reaches a return() with no argument, it behaves the same. It is allowed to omit the parenthesis.

/JeppeSN

Post to thread

Message boards : General discussion : Get prime from concatenating first n numbers

[Return to PrimeGrid main page]
DNS Powered by DNSEXIT.COM
Copyright © 2005 - 2022 Rytis Slatkevičius (contact) and PrimeGrid community. Server load 1.11, 1.43, 1.61
Generated 4 Jul 2022 | 3:09:35 UTC