I'm making a prime factorization program on my calculator. It works fine for smaller numbers, but it's showing strange behavior for 2^n, n≥47. It'll do fine for a while, but then at some point the program breaks down and after spitting out the prime numbers 17 and 353, keeps running forever.
With my extremely limited knowledge in programming, I'm suspecting that the calculator can't handle such a large number accurately and messes up the program.
Here's the code: (variables explained below; outputs prime factors in the form of A+Bi for a prime factor of A^B)
ClrHome
Disp "N=Number
Input "N: ",N
If N≥2 and not(fPart(N)):Then
0→dim(ʟP)
2→I
0→R
0→S
Repeat N=1
If not(fPart(N/I)):Then
While not(fPart(N/I))
N/I→N
S+1→S
End
R+1→R
I+Si→ʟP(R)
0→S
End
I+1→I
End
End
ʟP
#N: Number to be prime-factored (input)
#I: A prime factor
#R: Number of unique prime factors
#S: Exponent on prime factor
#ʟP: Prime factorization of N (output)
To reproduce this problem, run the program and input any 2^n for n≥47.
Anyone know why this is happening?