I want to make a method to find a number divisible by a number and add those numbers to an array to be printed out later when I call the method.
I made it to this point:
int [] divider(int n) {
int [] result = new int[20];
for (int i = 0; i <= n; i++) {
if (n%i == 0)
result = result[i];
}
return result;
}
I know it's wrong at many points, but I tried. This is the two thing I know I need to do, but I don't know how:
I know that I have the calculate how many numbers that divisible by a number first to know how big of an array to create. The problem is I know how to find how many number there are, but I don't know how to use that number to create an array by itself in the method.
After that I need to find what is those numbers in which it can divide by another number. This one I could do it, but I don't know how to add these result into an array to print out later.
These are what I know up until now. Please help. Thank you.