Basically I figured estimating the amount of primes below any number might be done more accurate if you first calculate the chance of a number being prime using the knowledge that for instance half of the numbers between 2^2 and 3^2 should be prime, and 1/2+(1-1/2)/3 between 3^2 and 5^2 etcetera. That's a terrible explanation, I know, so here's the program I devised for it:

```
Delvar L1
2->C
2->L1(C
Input "X: ",X
For(A,3,X^.5,2
For(B,3,A^.5,2
If 0=fPart(A/B
Goto 0
End
A->L1(C
C+1->C
End
Goto 1
Lbl 0
A^.5->B
End
End
Lbl 1
This generates a list of primes below the square root of X.
For(A,L1(dim(L1))+2,7919^2-1,2
For(B,3,A^.5,2
If 0=fPart(A/B
Goto 2
End
A->L1(C
7919^2-1->A
End
Goto 3
Lbl 2
A^.5->B
End
End
Lbl 3
This adds the first prime greater than X to the list.
2->Y
.5->Z
For(A,2,dim(L1)-1
Z+(1-Z)/L1(A->Z This calculates the chance of a number in between the squares of two primes being prime.
Y+(1-Z)(L1(A)^2-L1(A-1)^2)->Y This multiplies this chance with the amount of numbers between the squares of the primes, and adds this to the result of the chance multiplied by the amount of numbers between the squares of the previous two primes.
End
Y+(1-(Z+(1-Z)/L1(dim(L1))))(X-L1(dim(L1)-1)^2)->Y This adds the remainder of X minus the square of the highest prime lower than the square root of 10, multiplied by the chance of numbers in this remainder being prime.
Disp "Pi(X)=",Y
```