in reply to get next higher number
If this is not a homework question: Where do these numbers come from? What do they represent? How many numbers could there be? What is the maximum range of the numbers? How important is speed of calculation vs storage space? - Yes, that is a complicated question, but this is a common programming tradeoff. Knowing the answers to those basic questions and the overall context of your application would, with a high probability, lead to a more efficient solution and a "better" answer.
You wrote; "I prefer not to use any other functions or modules." Well, if(looks_like_number($row) calls a function that is not shown in your code.
Update: I don't see any Print statement in the original code. If there is no output, then any calculations are meaningless.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: get next higher number
by AnomalousMonk (Archbishop) on Jun 11, 2018 at 22:16 UTC | |
by ovedpo15 (Pilgrim) on Jun 12, 2018 at 06:30 UTC | |
by hippo (Archbishop) on Jun 12, 2018 at 07:48 UTC |