You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Richa and her daughter Ahaana are playing a game. Richa is going to tell one number and Ahaana need to tell the prime factors of the number. Help Ahaana by completing the code to find prime factor of the number. Write a method which calculate prime factors and print and call the method in main.
3
+
4
+
Input Format
5
+
6
+
An integer value
7
+
8
+
Constraints
9
+
10
+
N will be lie between 10-50
11
+
12
+
Output Format
13
+
14
+
All the prime factors will be printed exectly once with space.
15
+
*/
16
+
importjava.io.*;
17
+
importjava.util.*;
18
+
19
+
publicclassSolution {
20
+
21
+
staticvoidprimeFactor(intx)
22
+
{
23
+
if(x<=1)
24
+
return;
25
+
26
+
for(inti=2;i*i<=x;i++)
27
+
{
28
+
if(x%i==0)
29
+
{
30
+
System.out.print(i+" ");
31
+
while(x%i==0)
32
+
x /= i;
33
+
}
34
+
}
35
+
if(x>1)
36
+
System.out.print(x);
37
+
}
38
+
publicstaticvoidmain(String[] args) {
39
+
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
0 commit comments