how to find the divisors of a number in java
import java.util.*;class PrintDivisors{ public static void main(String args[]) { System.out.println("Enter the number"); // Create Scanner object for taking input Scanner s=new Scanner(System.in); // Read an int int n=s.nextInt(); // Loop from 1 to 'n' for(int i=1;i<=n;i++) { // If remainder is 0 when 'n' is divided by 'i', if(n%i==0) { System.out.print(i+", "); } } // Print [not necessary] System.out.print("are divisors of "+n); }}
Also in Java:
- How do you count characters in a string array in Java?
- java download file from url to string
- java int to binary
- java add element to existing array
- java catch multiple exceptions
- jtable disable row selection
- java polymorphism
- junit meaning in java
- java for in loop
- java script print date in YYYY-MM-DD format
- async in fragment
- map.keyset in java
- how to detect device javascirpt
- system.in example in java
- restart application programmatically android
- intellij replace all
- how to check the end of a string java
- how to compare string in java
- java program to display characters from a to z using loop
- get raondom from array java
- how to get witdth of window android
- Java Read Files
- java get excectuon time
- connecting to h2 database from java