OpenConsole() Procedure is89(x) Repeat s=0 While x : s+ x%10*x%10 : x/10 : Wend If s=89 : ProcedureReturn 1 : EndIf If s=1 : ProcedureReturn 0 : EndIf x=s ForEver EndProcedure Procedure main() Dim sums(32*81+1) : sums(0)=1 : sums(1)=0 For n=1 To n+1 For i=n*81 To 1 Step -1 For j=1 To 9 s=j*j : If s>i : Break : EndIf sums(i)+sums(i-s) Next Next count89=0 For i=1 To n*81+1 If Not is89(i) : Continue : EndIf If sums(i)>9223372036854775807-count89 PrintN("counter overflow for 10^"+Str(n)) ProcedureReturn 0 EndIf count89+sums(i) Next PrintN("1->10^"+LSet(Str(n),2,Chr(32))+": "+Str(count89)) Next EndProcedure start=ElapsedMilliseconds() main() Print("elapsed milliseconds= "+Str(ElapsedMilliseconds()-start)) Input()