The strange thing is that if I try to replicate the calculation error once the program is stopped it doesn't reproduce (?!)

first i wrote a simple code to perform the sequence from an INPUT A and count how many iterations did it take to reach the result A=1, it looked Ok but i wanted to test it I used the values that give the largest number of iterations from the chart in the wiki :

*The starting value having the largest total stopping time while being*

less than 10 is 9, which has 19 steps,

less than 100 is 97, which has 118 steps,

less than 1000 is 871, which has 178 steps,

less than 10^4 is 6171, which has 261 steps,

less than 10^5 is 77031, which has 350 steps,

less than 10^6 is 837799, which has 524 steps,

less than 10^7 is 8400511, which has 685 steps,

less than 10^8 is 63728127, which has 949 steps,

less than 10^9 is 670617279, which has 986 steps,

less than 10^10 is 9780657630, which has 1132 steps,[11]

less than 10^11 is 75128138247, which has 1228 steps,

less than 10^12 is 989345275647, which has 1348 steps,

less than 10^13 is 7887663552367, which has 1563 steps,

less than 10^14 is 80867137596217, which has 1662 steps,

less than 10^15 is 942488749153153, which has 1862 steps,

less than 10^16 is 7579309213675935, which has 1958 steps,

less than 10^17 is 93571393692802302, which has 2091 steps and

less than 10^18 is 931386509544713451, which has 2283 steps.

less than 10 is 9, which has 19 steps,

less than 100 is 97, which has 118 steps,

less than 1000 is 871, which has 178 steps,

less than 10^4 is 6171, which has 261 steps,

less than 10^5 is 77031, which has 350 steps,

less than 10^6 is 837799, which has 524 steps,

less than 10^7 is 8400511, which has 685 steps,

less than 10^8 is 63728127, which has 949 steps,

less than 10^9 is 670617279, which has 986 steps,

less than 10^10 is 9780657630, which has 1132 steps,[11]

less than 10^11 is 75128138247, which has 1228 steps,

less than 10^12 is 989345275647, which has 1348 steps,

less than 10^13 is 7887663552367, which has 1563 steps,

less than 10^14 is 80867137596217, which has 1662 steps,

less than 10^15 is 942488749153153, which has 1862 steps,

less than 10^16 is 7579309213675935, which has 1958 steps,

less than 10^17 is 93571393692802302, which has 2091 steps and

less than 10^18 is 931386509544713451, which has 2283 steps.

just to find the result corresponding to 8400511, which has 685 steps was not correct. then I added the lines to print "P" or "I" bellow the intermediate results according they were even(P) or odd(I), and check the result of the function storing the inicial value in B and comparing it when reverting the function in lines 106 and 126 leading to a STOP at that point.

**20 LET C=-1**

30 INPUT A

45 SCROLL

50 LET C=C+1

60 IF A=1 THEN GOTO 140

70 PRINT A

75 SCROLL

90 IF A/2=INT (A/2) THEN GOTO 120

95 PRINT "I"

100 LET B=A

105 LET A=(A*3)+1

106 IF (A-1)/3<>B THEN STOP

110 GOTO 40

120 LET B=A

121 PRINT "P"

125 LET A=A/2

126 IF A*2<>B THEN STOP

130 GOTO 40

140 PRINT ,C;" ITERACIONES"

160 RUN

30 INPUT A

45 SCROLL

50 LET C=C+1

60 IF A=1 THEN GOTO 140

70 PRINT A

75 SCROLL

90 IF A/2=INT (A/2) THEN GOTO 120

95 PRINT "I"

100 LET B=A

105 LET A=(A*3)+1

106 IF (A-1)/3<>B THEN STOP

110 GOTO 40

120 LET B=A

121 PRINT "P"

125 LET A=A/2

126 IF A*2<>B THEN STOP

130 GOTO 40

140 PRINT ,C;" ITERACIONES"

160 RUN

on the zeddy it aparently takes the wrong desition aobout beng odd for an even number and then inverting the funtion and comparing to B leads to STOP.

then I tried on the Spectrum, it fails on the same entry but sooner on the iterations...

**20 LET C=-1**

30 INPUT A

44 POKE 23692,2

50 LET C=C+1

60 IF A=1 THEN GO TO 140

70 PRINT A

72 POKE 23692,2

90 IF A/2=INT (A/2) THEN GO TO 120

95 PRINT "I"

100 LET B=A

105 LET A=(A*3)+1

106 IF (A-1)/3<>B THEN STOP

110 GO TO 40

120 LET B=A

121 PRINT "P"

125 LET A=A/2

126 IF A*2<>B THEN STOP

130 GO TO 40

140 PRINT ,C;" ITERACIONES"

160 GO TO 1

30 INPUT A

44 POKE 23692,2

50 LET C=C+1

60 IF A=1 THEN GO TO 140

70 PRINT A

72 POKE 23692,2

90 IF A/2=INT (A/2) THEN GO TO 120

95 PRINT "I"

100 LET B=A

105 LET A=(A*3)+1

106 IF (A-1)/3<>B THEN STOP

110 GO TO 40

120 LET B=A

121 PRINT "P"

125 LET A=A/2

126 IF A*2<>B THEN STOP

130 GO TO 40

140 PRINT ,C;" ITERACIONES"

160 GO TO 1

my concern is that I got an erroneous result and not an error message.

How to handle it is a different matter as well.