A friend of mine recently programmed a BASIC program that would calculate A X value (with no decimal part) for which there was an Y value (with no decimal part). In words: the program calculated a grid point of a given function Y=AX+B (intersection of the line AX+B with a grid node actually).
However I thought i could beat 10 seconds of calculating time for the function A=0.01 and B=0.01 (in which X should be 99 and Y should be 1). I did, at first, beat him because I used [repeat] instead of [while] however, HIS program is now running at 3 seconds for the same function (A=0.01 and B=0.01) but his program calculates not only X,X+1,X+2,X+3 etc but also X-1,X-2 etc. So he "scans" both positive and negative values of X for a non-decimal value of Y using the (or a) given formula. I think this time is beatable but I really suck at devising algorithms so…here is the question: Any ideas on how to make a FAST as possible program for "scanning" both on the + and - side of the Horizontal axis?
Thanks In Advance.
If you have any questions regarding my poor explanation..please ask.