Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Problem_5
- {
- public static void main(String[] args)
- {
- // num is what will look for answer
- // answer will be set to num when found
- // n is for recursively dividing
- int num = 20, answer = 0, n = 1;
- // while the answer has not been found
- // continue searching
- while (answer == 0)
- {
- n = 1;
- // set dividor back to 1 and start again
- while (n <= 20)
- {
- if ((num % n) == 0)
- n++;
- }
- if ((num % 20 == 0) && (n == 20))
- {
- answer = num;
- System.out.print("The answer is: " + answer);
- }
- num++;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment