FIND FACTORS OF NUMBERS

 package com.cnc;


public class Main {

public static void main(String[] args) {
printFactors(15);
}

public static void printFactors(int number) {
if (number < 1) System.out.println("Invalid Value");
else
for (int a = 1; a <= number; a++) {
if ((number % a == 0)) {
System.out.println(a);
}
}
}
}

Popular posts from this blog

NUMBER PALINDROME CHALLENGE

ENCAPSULATION CHALLENGE

LARGEST PRIME FACTOR OF A NUMBER