Let Sp(n) be a sum of all primes from p(1) to p(n) inclusive.
Let m(n) be the average value of all those primes, i.e. m(n)= Sp(n)/n.
Find the n-th prime N such that m(n) equals the reversal of N.
Example for n=6: Sp(6)=2+3+5+7+11+13= 41; m(6)=41/6; not the reversal of 13,
that is 31 .
So 13 is not our prime.
Another 2-digit number is.
Find it.
Are there any additional i.e. "numbers over 100" solutions?
For n=23, p(n)=83, Sp(n)/n=38
The code lists all integer Sp(n)/n for p(n) < 100,000 and this is the only one that complies. (I do not see how to prove there are no more.)
n P(n) Sp(n)/n
----------------------------------------------------
23 83 38.0000000
53 241 110.000000
853 6599 3066.00000
5034 48989 23066.0000
5233 51137 24091.0000
6162 61223 28921.0000
6658 66809 31535.0000
6752 67783 32033.0000
6974 70379 33213.0000
7098 71707 33874.0000
7177 72559 34295.0000
7228 73091 34567.0000
7231 73133 34583.0000
7396 75017 35465.0000
7698 78439 37084.0000
7706 78539 37127.0000
7738 78889 37299.0000
7840 80051 37848.0000
7975 81547 38575.0000
8006 81883 38742.0000
8127 83233 39394.0000
8793 90901 43007.0000
8970 92849 43972.0000
9050 93787 44408.0000
9085 94169 44599.0000
program pp
implicit none
integer i,n,cnt,sum,iave
real ave
sum=2
cnt=1
do i=3,100000,2
call isprime(i,n)
if(n.eq.1)then
cnt=cnt+1
sum=sum+i
ave=(1.*sum)/(1.*cnt)
iave=ave
if(abs(iave-ave).lt.0.001)print*,cnt,i,ave
endif
enddo
end
subroutine isprime(i,n)
implicit none
integer i,j,k,l,m,n
n=0
k=sqrt(1.*i)
do j=3,k
m=(1.*i)/(1.*j)
l=m*j
if(l.eq.i)go to 1
enddo
n=1
1 return
end
Edited on October 10, 2018, 8:32 pm