What you need to do will be separated into 2 parts - find the first divisible number and a loop which is increment by X up to the max. The second part is easy and you should be able to do it. Now we need to talk about the first part.
hfx642 algorithm is OK but it is a brute-force which could be costly. If let say min is 1234, max is 987654321, and X is 999999, How many times do you have to go through the loop to find the first divisible number?
What you could actually do is a simple arithmetic. Think about it. If the X value is already a divisible value of the min, the min itself is already the first divisible number, correct? Now, if it is not, then the modulo value could be used to find the first divisible number! *hint hint*
PS: You also need to check whether X is less than max before you attempt to find the first divisible number.
Hey, so I wanna ask how I need to create a method who will remove word if in that word is 2 same chars. Example: "Potato" in this word there is a 2 "o" chars so this word will need to be removed. "Forum" in this word there is no ...
Help! I want to create a java program that finds the highest even integer among the values entered by the user. Stop asking values when a value less than 1 have been entered. If no even integer is entered, display "No Even Integer"
I am writing a java program that needs to execute shell commands, so I wrote a function that would take the command to execute as a string (ie: "mkdir ~/Folder1") and execute that command with the shell. Here is the function:
Runtime run = Runtime.getRuntime();
Process pr = ...