A number theory problem by Anmol Jain

Find the sum of all primes of the form p = n n + 1 p=n^{n} + 1 , where p < 1 0 19 p<10^{19} and n n is a positive integer.


The answer is 264.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

8 solutions

Naren Bhandari
May 14, 2018

My approach

We notice that for n = 1 , 2 n=1,2 p = 2 , 5 p= 2,5 which are obviously the prime numbers . Further we have that p < 1 0 19 n n + 1 < 1 0 19 p<10^{19}\implies n^n+1 <10^{19} . Taking log \log on both sides we get that log ( n n + 1 ) log ( 1 0 19 ) > 1 \frac{\log(n^n+1)}{\log(10^{19})} > 1 for n = 16 n=16 and log ( n n + 1 ) log ( 1 0 19 ) < 1 \frac{\log(n^n+1)}{\log(10^{19})} < 1 for n = 15 n=15 . Thus, the range of n n is 1 n < 16 1\leq n <16 . .


If n = k b n = kb where k k is an odd number greater than 1. Then n n + 1 = ( n b ) k + 1 n^n+1 = (n^b)^k+1 is divisible by n b + 1 n^b+1 ( by factorization ) of a n + b n a^n+b^n . Hence we arrived that n n must be an even number.

Let n = 2 l n =2l and primes number are expressed as 2 k 1 + 1 = n n + 1 l = 2 k 1 2 l 2 2k_1+1 = n^n+1\implies {\color{#3D99F6}l = \frac{\sqrt[2l]{2k_1}}{2}} . This must be in form power of 2 if not then n n + 1 n^n+1 is composite. Working out with 2 , 4 , 8 2,4,8 . Only n = 2 , 4 n= 2,4 are possible values. Hence , the required primes we have 1 1 + 1 , 2 2 + 1 , 4 4 + 1 1^1+1,2^2+1, 4^4+1 . Hence , the sum of primes we have is 2 + 5 + 257 = 264 \boxed{2+5+257 =264} .

Note 8 8 doesn't work since 8 8 8^8 has odd divisors in it power tower.

Moderator note:

These are known as Sierpiński Numbers of the First Kind.

Note if we don't restrict the upper bound of p p this is an open question. The full list of primes (the ones given in this answer) have only been confirmed for p p less than 1 0 3 ( 10 ) 20 . 10^{3(10)^{20}} .

Further information here. (External link.)

BRO 2+5+257=264

Anmol Jain - 3 years ago

Log in to reply

It's typo. I have fixed it. Thanks !!

Naren Bhandari - 3 years ago

Log in to reply

The boxed text currently reads 1+5+257=264, so I guess you haven't fully fixed it.

Log in to reply

@Roland van Vliembergen oh! My bad . Thanks I have fixed it now. :)

Naren Bhandari - 2 years, 10 months ago

Why must n be in the form of 2^k?

Laszlo Kocsis - 3 years ago

Log in to reply

I have changed the solution. If it n isnot I'm form of 2^k then the n^n+1 is a composite .

Naren Bhandari - 3 years ago

Why you shouldn't take n=12 to solving the primes?

Dhanu Siva - 3 years ago

Log in to reply

I have changed the solution. Hope it can help you. :)

Naren Bhandari - 3 years ago

Why are we not working with 2,4,8 and not with 2,4,6,8????

erica phillips - 3 years ago
Giorgos K.
May 5, 2018

using M a t h e m a t i c a Mathematica

#^#+1&/@Select[Range@19,PrimeQ[#^#+1]&]

returns {2, 5, 257}

Thank you Mike. That is very very helpful for me. Cheers, Michael

Michael Leslie Troth - 2 years, 12 months ago

hahaha good meme

Stanley Zhao - 2 years, 10 months ago
Anmol Jain
May 5, 2018

For n = 1 n=1 and n = 2 n=2 , we get primes. An odd n > 1 n>1 yields an even n n + 1 > 2 n^n+1>2 . So n n must be even, i.e n = 2 2 t ( 2 k + 1 ) n=2^{2^t}(2k+1) .

Since 2 2 t + 1 2 2 t ( 2 k + 1 ) + 1 2^{2^t}+1\bigg|2^{2^t}(2k+1)+1 , the exponent of n n cannot have an odd divisor. Thus n + 2 2 t n+2^{2^t} or n n = ( 2 2 t ) 2 2 t \displaystyle n^n=\big(2^{2^t}\big)^{2^{2^t}} . For t = 0 , 1 t=0,1 we get n n + 1 = 5 , 257 n^n+1=5,257 , but when t = 2 t=2 , p = 1 6 16 + 1 = 2 64 + 1 > 16 100 0 6 + 1 > 1 0 19 p=16^{16}+1=2^{64}+1>16\cdot1000^6+1>10^{19} . So there are no other primes besides 2 , 5 , 257 2,5,257 .

@Anmol Jain Kindly use latex as it is disturbing to understand such answers otherwise......

Anurag Bisht - 3 years, 1 month ago

Log in to reply

BRO IT WILL CONSUME ALOT OF MY TIME

Anmol Jain - 3 years, 1 month ago

Log in to reply

But without it your statement will be ignored by most ....and press the caps lock button once please.

Anurag Bisht - 3 years, 1 month ago

Log in to reply

@Anurag Bisht BRO TODAY YOU WILL TEACH ME HOE TO WRITE A SOLUTION IN FIITJEE OK

Anmol Jain - 3 years, 1 month ago

Log in to reply

@Anmol Jain Just write latex in your brilliant search bar.....you will get all formulas....see them and type...its easier than remembering

Anurag Bisht - 3 years, 1 month ago

Log in to reply

@Anurag Bisht THANKS FOR ENLIGHTENING MY MIND

Anmol Jain - 3 years, 1 month ago

Log in to reply

@Anmol Jain Capslock............

Anurag Bisht - 3 years, 1 month ago

Log in to reply

@Anurag Bisht Thanks is it ok now sir?

Anmol Jain - 3 years, 1 month ago

Log in to reply

@Anmol Jain Yes, My Lad.

Anurag Bisht - 3 years, 1 month ago

Log in to reply

@Anurag Bisht Bro why don't we make a class and add all good students of our school

Anmol Jain - 3 years, 1 month ago

Let me rewrite his solution: For n = 1 n=1 and n = 2 n=2 , we get primes. An odd n > 1 n>1 yields an even n n + 1 > 2 n^n+1>2 . So n n must be even, i.e n = 2 2 t ( 2 k + 1 ) n=2^{2^t}(2k+1) .

Since 2 2 t + 1 2 2 t ( 2 k + 1 ) + 1 2^{2^t}+1\bigg|2^{2^t}(2k+1)+1 , the exponent of n n cannot have an odd divisor. Thus n + 2 2 t n+2^{2^t} or n n = ( 2 2 t ) 2 2 t \displaystyle n^n=\big(2^{2^t}\big)^{2^{2^t}} . For t = 0 , 1 t=0,1 we get n n + 1 = 5 , 257 n^n+1=5,257 , but when t = 2 t=2 , p = 1 6 16 + 1 = 2 64 + 1 > 16 100 0 6 + 1 > 1 0 19 p=16^{16}+1=2^{64}+1>16\cdot1000^6+1>10^{19} . So there are no other primes besides 2 , 5 , 257 2,5,257 .

Kelvin Hong - 3 years ago

Log in to reply

But I don't know why if n n is even then n = 2 2 t ( 2 k + 1 ) n=2^{2^t}(2k+1) , isn't it n = 2 t ( 2 k + 1 ) n=2^t(2k+1) ?

Kelvin Hong - 3 years ago

In general n^n+1 can only be prime if n is a tower exponent of 2s so n=1,2,2^2 and they all work here.

Pau Cantos - 3 years ago

Log in to reply

Is there a proof that n must be a tower exponent of 2s in order for the expression to be prime?

Maurice Wei - 3 years ago

Log in to reply

Sorry I was wrong in my statment, l can only proof that n must be of the form 2^2^k (wich is the same thing in the Interval (0,10^19) and is what Naren Bhandari has already proved).

Pau Cantos - 3 years ago

Why only tower of two

BETTER CODER - 2 years, 10 months ago
Ron van den Burg
May 20, 2018

Factorise n n in prime factors and separate it into two parts: the powers of 2 and the rest: n = 2 m ( 2 r + 1 ) n=2^m (2r+1) , where m m and r r are non-negative integers.

n n + 1 = n 2 m ( 2 r + 1 ) + 1 = ( n 2 m ) 2 r + 1 + 1 2 r + 1 n^n+1=n^{2^m (2r+1)}+1=(n^{2^m})^{2r+1}+1^{2r+1}

This result is in the form A s + B s A^s+B^s which is divisible by A + B A+B for odd s s .

The only way that there is a possibility for n n to be prime, is if the divisor equals n n or r = 0 r=0 .

So n = 2 m n=2^m .

m = 0 n = 1 n n + 1 = 2 m=0\implies n=1\implies n^n+1=2 which is prime 1.

If m > 0 m>0 , then also 'separate' m m : m = 2 t ( 2 u + 1 ) m=2^t (2u+1) leading to n n + 1 = ( 2 2 t ( 2 u + 1 ) ) 2 2 t ( 2 u + 1 ) + 1 = 2 2 t ( 2 u + 1 ) 2 2 t ( 2 u + 1 ) + 1 = ( 2 2 t 2 2 t ( 2 u + 1 ) ) 2 u + 1 + 1 n^n+1=(2^{2^t (2u+1)})^{2^{2^t (2u+1)}}+1=2^{2^t (2u+1) 2^{2^t (2u+1)}}+1 = (2^{2^t 2^{2^t (2u+1)}})^{2u+1}+1

Again, this can only be prime if u = 0 u=0 . Therefor, n = 2 2 t n=2^{2^t} are the only candidates.

t = 0 n = 2 n n + 1 = 5 t=0\implies n=2\implies n^n+1=5 (prime 2)

t = 1 n = 4 n n + 1 = 257 t=1\implies n=4\implies n^n+1=257 (prime 3)

t = 2 n = 16 n n + 1 = 1 6 16 + 1 = 2 64 + 1 > 2 4 2 60 = 16 ( 2 10 ) 6 = 16 102 4 6 > 16 1 0 18 > 1 0 19 t=2\implies n=16\implies n^n+1=16^{16}+1=2^{64}+1>2^4 2^{60}=16 (2^{10})^6=16 * 1024^6>16 * 10^{18}>10^{19} so we are done finding candidates.

Final answer 2 + 5 + 257 = 264 2 + 5 + 257=264 .

Mihir Mallick
May 16, 2018

Here is my approach: First observe that n = 1 n=1 is a trivial solution. Suppose, n > 1 n>1 .It is also easy to see that n n must be even

Claim 1: n is a power of 2 \textbf{Claim 1: n is a power of 2}

We prove this by contradiction. It is known that n n is even, so let n = 2 t c n=2^tc for some integer t t and an odd number (greater than 1 1 ) c c . Then,

n n + 1 = ( 2 t c ) 2 t c + 1 = ( ( 2 t c ) 2 t ) c + 1 n^n+1=(2^tc)^{2^tc}+1=((2^tc)^{2^t})^c+1

Since c c is odd, ( 2 t c ) 2 t + 1 (2^tc)^{2^t}+1 is a divisor of the above number, and hence it's not a prime. This proves our first claim.

Claim 2: n is a Fermat prime \textbf{Claim 2: n is a Fermat prime} This was proved by Fermat himself that if a number of the form 2 k + 1 2^k+1 is a prime, then k k is a power of 2 2 . (The proof of this is similar to the above one). Fermat number ( F n F_n ) is a number of the form 2 2 n + 1 2^{2^n}+1 . Thus F 0 = 3 , F 1 = 5 , F 2 = 17 , F 3 = 257 , F 4 = 65537 F_0=3,F_1=5,F_2=17,F_3=257,F_4=65537 and so on. Since F 6 > 1 0 19 F_6>10^{19} we have to consider only F 0 , F 1 , F 2 , F 3 , F 4 , F 5 F_0,F_1,F_2,F_3,F_4,F_5 . F 5 F_5 is a composite number. (This was proved by Euler).

We have shown that n n is a power of 2 2 . i.e. n = 2 k n=2^k for some positive integer k k . Thus, n n + 1 = ( 2 k ) 2 k + 1 = 2 k 2 2 k + 1 n^n+1=(2^k)^{2^k}+1=2^{k2^{2^k}}+1 Since this must be a Fermat prime, k 2 k = 2 t k2^k=2^t for some integer t t . Checking all the cases, we see ( k , t ) = ( 1 , 1 ) , ( 2 , 3 ) (k,t)=(1,1),(2,3) are the only solutions. Thus the sum of all such numbers is 2 + F 1 + F 3 = 2 + 5 + 257 = 264 2+F_1+F_3=2+5+257=\boxed{264}

actually without involve fermat prime numbers, it can be showed that also n=8 doesn't give a prime number,

Davide Lombardi - 3 years ago
Hao Fu
May 16, 2018

When p=2,5 with n=1,2,they're obviously prime.And we can easily notice that n^n+1 is always even when n is odd,so the odd numbers except 1 are all eliminated.

In fact,because 2^10=1024>10^3,we can know that 16^16=(2^4)^16=(2^10)^6 2^4>10^18 10=10^19,with which we know n<16.

Now comes the key part ,to shrink the range the last time,we can use a equality of factorization as below.

When k is an odd number, we have

n^k+1=(n+1)(n^(k-1)-n^(k-2)+n^(k-3)-…-n+1)

So 6^6+1=(6^2)^3+1,8^8+1 =(2^8)^3+1,10^10=(10^2)^5+1,12^12=(12^4)^3+1,14^14=(14^2)^7+1 out at the same time.

And examine 4^4+1 in the end,we get the answer 2+5+257=264

Jason Martin
May 15, 2018

Suppose n = m k n=mk for odd integer m > 1 m>1 . Then n n + 1 = n m k + 1 = ( n k + 1 ) ( n ( m 1 ) k n ( m 2 ) k + + 1 ) n^n+1=n^{mk}+1=(n^k+1)(n^{(m-1)k}-n^{(m-2)k}+\ldots +1) , so in order for n n + 1 n^n+1 to be prime, n n cannot have an odd divisor greater than 1 1 . Thus, n n must be a power of 2 2 , so let n = 2 k n=2^k . Then n n + 1 = 2 k 2 k + 1 n^n+1=2^{k2^k}+1 . By a similar argument, k k cannot have any odd divisors greater than 1 1 , and thus must also be a power of 2 2 (or k = 0 k=0 ). If k = 2 s k=2^s , then n n + 1 = 2 2 s + 2 s + 1 n^n+1=2^{2^{s+2^s}}+1 .

Thus, if this quantity is prime, then in particular it is a Fermat prime. Only 5 5 Fermat primes are known: 3 , 5 , 17 , 257 , 3, 5, 17, 257, and 65 , 537 65,537 . Only 2 2 have the specified form, namely 5 5 and 257 257 . Since k k could be 0 0 , we also have n = 1 n n + 1 = 2 n=1 \implies n^n+1=2 is another solution. Therefore, the answer is 2 + 5 + 257 = 264 2+5+257=\boxed{264} .

Alex Li
May 15, 2018

Let's write some code! Python's the best language for this problem since it can easily handle big numbers, and 10^19 is just barely large enough to be annoying for most languages (In java you could use BigInteger but in some languages you'll just have to make your own structure D:)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
def isPrime(X):
    factor=2;
    # This while loop claims that if any number X has no factors between 2 and sqrt(x), then X is a prime. 
    # Proof by contradiction: Suppose x is composite.  Then it has 2 factors a and b such that a*b=X.
    # a is greater than sqrt(X), but then b must be greater than sqrt(X), Contradiction! 
    while(factor*factor<=X): 
        if(X%factor==0):
            return False;
        factor+=1;
    return True;

#code begins running here
n = 1
prime_sum = 0
while(n**n<=10**19):
    val = n**n+1;
    if(isPrime(val)):
        prime_sum+=val;
    n+=1;
print(prime_sum);

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...