Computer Science, asked by naina7415, 4 months ago

Write a program in java to accept a number from the user and print all the factors . Please answer this as fast as possible

Answers

Answered by manavpaul27
2

Answer:

Hope this helps

Explanation:

package SimplerPrograms;

import java.util.Scanner;

public class FactorsOfNumberUsingFor {

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);

}

}

}

}

Similar questions