PowerMax=10
#..................................................................
#..................SAGE.CODE.USED.TO.BUILD.........................
#.......................THE.TABLE.OF...............................
#.........................pi.and.Li................................
#..................................................................
#.....................PLEASE.FEEL.FREE.............................
#.....................TO.SEND.COMMENTS.............................
#..................................................................
#..............Sage.is.a.free.open-source..........................
#..............mathematics.software.system.........................
#................licensed.under.the.GPL............................
#...............http://www.sagemath.org/...........................
#..................................................................
Premiers=prime_range(10^PowerMax)
l=len(Premiers)
#..........................................
var('t')
Li=lambda a,b: numerical_integral(1/log(t),a,b)[0]
#..........................................
Z=[]
S=0
j=0
li=0
a=2
b=10
for i in range(1,PowerMax+1):
        li+=Li(a,b)
        a=b
        b=10*b
	while Premiers[j]<10^i: 
         j+=1
         if j>=l:
          break
     	S=j
	Z.append([10^i,S,li,li -S,(li-S)/S*100])
lz=len(Z)
#..........................................	
Nom_fichier='Tableau_Pi_Li'+str(PowerMax)+'.html'
o=open(Nom_fichier,'w')
o.write('<table border="1" >')
o.write('\n')
o.write('<tr>')
o.write('\n')
o.write('<td><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>n</mi></math></td><td><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>&pi;(n)</mi></math></td><td><math xmlns="http://www.w3.org/1998/Math/MathML"><mi mathvariant="normal">Li</mi><mi>(n)</mi></math></td><td><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>&pi;(n)-</mi><mi mathvariant="normal">Li</mi><mi>(n)</mi></math></td><td>Erreur (%)</td>')
o.write('\n')
o.write('</tr>')
o.write('\n')
for i in range(lz-1):
   o.write('<tr>')
   o.write('\n')
   o.write('<td>'+str(Z[i][0])+'</td><td>'+str(Z[i][1])+'</td><td>'+str(Z[i][2])+'</td><td>'+str(Z[i][3])+'</td><td>'+str(RR(Z[i][4]).n(digits=3))+'</td>')
   o.write('\n')
   o.write('</tr>')
o.write('\n')
o.write('</table>')
o.close()
  
