- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Find all divisors of a natural number in java
Following is the Java program which prints all the divisors of a given number.
Program
import java.util.Scanner; public class DivisorsOfNaturalNumber { public static void main(String args[]) { Scanner sc = new Scanner(System.in); System.out.println("Enter required number :"); int num = sc.nextInt(); for(int i = 1; i<num; i++) { if(num % i == 0) { System.out.println(" "+i); } } } }
Output
Enter required number : 200 1 2 4 5 8 10 20 25 40 50 100
- Related Articles
- Find sum of divisors of all the divisors of a natural number in C++
- Sum of all proper divisors of a natural number in java
- Find all divisors of a natural number - Set 1 in C++
- Find all divisors of a natural number - Set 2 in C++
- Count all perfect divisors of a number in C++
- Divisors of factorials of a number in java
- Find the number of divisors of all numbers in the range [1, n] in C++
- Check if a number is divisible by all prime divisors of another number in C++
- Find number from its divisors in C++
- Find largest sum of digits in all divisors of n in C++
- Counting divisors of a number using JavaScript
- Find the largest good number in the divisors of given number N in C++
- Find the number of all three digit natural numbers which are divisible by 9.
- How to find the natural logarithm of a number in TypeScript?
- Minimum number of Square Free Divisors in C++

Advertisements