Computer Science, asked by lilsa, 5 months ago

Write a program in java to accept a number from user and print all the factors.

Please answer fast​

Answers

Answered by SP85
2

So I will solve it by using scanner class and loop

Let's begin

import java.util.Scanner;

class Factors Of Number

{

private static Scanner sc;

public static void main(String[] args)

{

int Number, i;

sc = new Scanner(System.in);

System.out.println("Please Enter any number to Find Factors: ");

Number = sc.nextInt();

for(i = 1; i <= Number; i++)

{

if(Number%i == 0)

{

System.out.format(" %d ", i);

}

}

}

}

Solved

If you want more help then follow I will get notifications

Similar questions