Find the prime factorization of all integers in the interval [a, b].
Input format:
Input two integers a, b. Data scale and convention 2<=a<=b<=10000
Output format:
each line outputs a decomposition of a number, like k=a1a2a3...(a1<=a2<=a3..., k is also from small to large) (see the example for details)
Input sample:
Here is a set of input. For example:
3 10
Output sample:
The corresponding output is given here. For example:
3=3
4=2 2
5=5
6=2 3
7=7
8=2 2 2
9=3 3
10=2 5
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int num ;
int a = sc.nextInt();
int b = sc.nextInt();
for (int i = a; i <= b; i++) {
System.out.print(i + "=");
num = i ;
for (int j = 2; j <= i/2; j++) {
while (num % j == 0) {
num = num / j;
System.out.print(j);
if (num != 1)
System.out.print("*");
}
}
if (num==i){
System.out.print(i);
}
System.out.println();
}
}
}