public class Main {
public static void main(String[] args) {
// positive number
int number = 6;
System.out.print("Factors of " + number + " are: ");
// loop runs from 1 to 60
for (int i = 1; i <= number; ++i) {
// if number is divided by i
// i is the factor
if (number % i == 0) {
System.out.print(i + ",");
}
}
}
}
And my output is "1,2,3,6," but i want it like "1,2,3,6" How can i do that?
No matter what i do it did not worked.