PasteBin Link
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++; }}}
If it doesn't work, I will probably have to make some logic adjustments. Have not tried this in Mathematica yet, the if statements and while loops are very different syntactically from Java.
No comments:
Post a Comment