Created
August 8, 2019 09:52
-
-
Save 0ryant/661c7eab409b3833b59a9a6b2b9feff2 to your computer and use it in GitHub Desktop.
Java - Coding Challenge - Print All Factors of an Integer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void printFactors(int number){ | |
if (number <1){ | |
System.out.println("Invalid Value"); | |
} | |
String factors=""; | |
for (int i = 1;i<=number;i++){ | |
if(number%i==0){ | |
factors+=i+" "; | |
} | |
} | |
System.out.println(factors); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
import java.util.Scanner;
public class Solution {
}