Showing posts with label fector of a number. Show all posts
Showing posts with label fector of a number. Show all posts

Sunday, June 21, 2020

Write a program to find the Factors or all Divisors of number? (6..fector…(1,2,3,6) )

29)  Write a program to find the Factors or all Divisors of number? (6..fector…(1,2,3,6) )

import java.util.*;
public class Factors
{
   public static void main(String args[ ])
    {
        Scanner sc = new Scanner (System.in);
        System.out.println("Enter a number");
        int a = sc.nextInt();
        System.out.print("Factors of "+a+" = ");
        for(int i=1;i<=a;i++)
        {
            if(a%i==0)
            System.out.print(i+" ");
        }
    }
}

 jhvghvgk ;nkjn ,nkjhj