14: Topic Description
Function: Enter a positive integer that outputs all of its prime number factors in order from small to large (for example, a prime factor of 180 is 2 2 3 3 5)
Detailed Description:
Function Interface Description:
Public String GetResult (long Uldatainput)
Input parameters:
Long uldatainput: The positive integer entered
return value:
String
Input Description: Enter a long integer
Output Description: A factor that outputs all of its prime numbers in order from small to large, separated by a space
Input Example: 180
Output Example: 2 2 3 3 5
Packageprctice01;ImportJava.util.Scanner;/*Title Description Function: Enter a positive integer, the factor that outputs all of its prime numbers in order from small to large (for example, a prime factor of 180 is 2 2 3 3 5) Detailed description: Function interface Description: Public String getresult (long uldatainput) input parameter : Long uldatainput: Input positive integer return value: String input Description: Enter a long integer output description: A factor that outputs all of its prime numbers in order from small to large, with spaces separating the input example: 180 Output Example: 2 2 3 3 5< /c6>*/ Public classPrimeNum14 { Public Static voidMain (string[] args) {Scanner in=NewScanner (system.in); Longnum =In.nextlong (); StringBuilder SB=NewStringBuilder (); intDivide = 2; while(num! = 1) { while(Num%divide = = 0) {sb.append (divide+" "); Num= num/divide; } Divide++; } System.out.println (SB); }}
14: Prime number Factor Primenum