` ``--Prime Generation-- {2,3,5,7→L₁ {5→L₂ For(P,11,N,6) If min(remainder(P,L₂ P→L₁(1+dim(L₁ If min(remainder(P+2,L₂ P+2→L₁(1+dim(L₁ √(P+8 If max(L₁=Ans Ans→L₂(1+dim(L₂ End --Mobius Generation-- N→dim(L₂ Fill(1,L₂ For(L,1,dim(L₁ L₁(L→X For(M,1,N/Ans -L₂(MX→L₂(MX End L₁(L)²→X For(M,1,N/Ans 0→L₂(MX End End`

` ``startTmr->T Repeat checkTmr(T:End 999->N N->dim(L1 Fill(1,L1 {2,3->L2 For(P,5,N,2) If min(remainder(P,L2 P->L2(1+dim(L2 End Disp checkTmr(T startTmr->T Repeat checkTmr(T:End For(I,1,dim(L2 For([recursiven],L2(I),N,L2(I) ~L1([recursiven]->L1([recursiven] End End For(I,1,sum(not(cumSum(L2>sqrt(N //# of primes less than sqrt For([recursiven],L2(I)^^2,N,L2(I)^^2 0->L1([recursiven] End End Disp checkTmr(T`

It's also possible to speed up the algorithm by ~20%* or so by special-casing the primes 2 and 3.

*pretty much a complete guess tbh

]]>Also, something like `L4(L2(X` is legal syntax, but fixing the program means it's no longer necessary.

` ``SetUpEditor L2,L3,L4 Input "Min:",Z Input "Max:",N //Begin finding the primes {2,3→L₂ For(P,Z,N,2) If min(remainder(P,seq(A,A,3,1+√(P),2 P→L₂(1+dim(L₂ End //Once Primes are found, start the rest of the program L2^2->L3 //Store the squares to L3 N-Z->Dim(L4) //Set the length of the list Fill(1,L4 //Fill the List For(R,1,dim(L2 //for the length of the list of the primes L2(R) //get the value of the current prime -1->L4(Ans) //set that number to -1 in Mobius List End For(R,1,dim(L3 //for the length of list of squares L3(R) //get the value of the current square 0->L4(Ans) //set that number to 0 in mobius list, completing your mobius End ClrHome Pause L4 Delvar L2 Delvar L4`

Which may be able to be the following if I am correct; but Im sure It may be able to be optimized more:

` ``SetUpEditor L2, L4 Input "Min:",Z Input "Max:",N {2,3→L₂ For(P,Z,N,2) If min(remainder(P,seq(A,A,3,1+√(P),2 P→L₂(1+dim(L₂ End N-Z->Dim(L4) Fill(1,L4 For(R,1,dim(L2 L2(R) -1->L4(Ans) L2(R) //here is where it is different Ans^2 //square whatever value we are on, rather than using another list 0->L4(Ans) End ClrHome Pause L4 Delvar L2 Delvar L4`

` ``Create a list |LP of primes Store the squares of those primes to |LS Create a list |LM of 50 ones For each prime P in |LP: Negate every Pth element of |LM For each square S in |LS: Set every Sth element of |LM to zero`

That should be fairly easy to implement in TI-BASIC, and probably finish in about a second for N=50.

]]>` ``prgmPRIME //This is a separate program that generates all the primes up to N and stores them to L₁ {1→L₃ For(I,2,N Delvar JClrList L₂ Repeat L≥L/2 J+1→J L₁(J→L If not(remainder(I,Ans Ans→L₂(1+dim(L₂ If not(remainder(I,Ans² 0→L₂(1 End If max(I=L₁ {1→L₂ (min(L₂)≠0)(-1)^dim(L₂→L₃(1+dim(L₃ End`

List of Mobius Function values up to N are in L₃. ]]>