Algo-ma-rithm 2 - excel mistake? (1 Viewer)

-X-

Member
Joined
Aug 10, 2003
Messages
481
Gender
Undisclosed
HSC
N/A
PHP:
Begin convert_to_binary ( DecNum )
                                index = 1;
                                REPEAT
                                       Remainder = DecNum MOD 2;
                                       DecNum = DecNum / 2
                                       binary_index(index) = Remainder 
                                       increment index
                                UNTIL DecNum <= 0
                                Counter = index - 1
                                While counter > = 1
                                        PRINT binary_array(counter)
                                        counter = counter + 1          //Shouldn't that be - 1?
                                 ENDWHILE
End SUBPROGRAM
Shouldn't it be counter = counter - 1 so that it prints the array backwards?


Thanks
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top