1. 


/**
* Angewandte Mathematik, SS09, IFB 2C
* ACM Problem #10392 (Factoring Large Numbers)
* Link: http://icpcres.ecs.baylor.edu/onlinejudge/index.php?option=com_onlinejudge&Itemid=8&category=15&page=show_problem&problem=1333
*
* @author Christian Posselt
* @author Jonathan Schubert
* @version 1.0, 03/30/2009
*
* Status : Accepted
* Runtime: 0.550
*/

import java.util.Scanner;

class Main {


public static void main(String[] args) {

//setting up all needed variables
Scanner sc = new Scanner(System.in);
Long n, number_org;

while(sc.hasNext())
{

//Read-in of a number
number_org = sc.nextLong();
n = number_org;

if(number_org<0)
break;

//print out factors
//check if "2" is a factor.
if(n%2==0)
{
while(n%2==0)
{
n = n/Long.parseLong("2");
System.out.println(" " + 2);
}
}

//finding the main factors
for(Long j=Long.parseLong("3"); j*j<=n;j+=2)
if(n%j==0)
{
while(n%j==0)
{
n = n/j;
System.out.println(" " + j);
}
}

//test if the remaining n is divisor of number_org
if(number_org%n==0)
System.out.println(" " + n);

//SystemOut
System.out.println();

}
}

}

2.

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Main
{
/**
* Angewandte Mathematik, SS09, IFB 2C
* ACM Problem #10392 (Factoring Large Numbers)
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=15&page=show_problem&problem=1333
*
* @author Christian Posselt
* @author Jonathan Schubert
* @version 1.0, 05/24/2009
*
* Status : Accepted
* Runtime: 0.148
*/

public static void main(String[] args) throws IOException
{

StringBuilder builder = new StringBuilder();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String line;
while(true)
{
long number = 0;
line = reader.readLine();
//end of input
if(line == null)
break;
StringTokenizer t = new StringTokenizer(line);
while(t.hasMoreTokens())
{

number = Long.parseLong(t.nextToken());
if(number <= 0)
break;

//print testnumber = and -1 if testnumber < 0
builder = facts(Math.abs(number),builder);
builder.append("\n");
}
if(number <= 0)
break;
}
builder.deleteCharAt(builder.length()-1);
System.out.println(builder.toString());
}

public static StringBuilder facts(long n,StringBuilder builder)
{
//get all factors off 2
while(n%2==0)
{
n/=2;
builder.append(" 2\n");
}

//no factors left in n
if(n==1)
return builder;

//get odd factors of n
for(long j=3; n!=1 && j*j<=n; j+=2)
{
while(n%j==0)
{
n/=j;
builder.append(" "+j+"\n");
}
}
//after this if n > 1 n must be prim
if(n > 1)
{
builder.append(" "+n+"\n");
}
return builder;
}
}

3.

/**
* Angewandte Mathematik SS 09
10392 Factoring Large Numbers
* UVa Status: Accepted
* Run Time: 0.170
* Programming Language: C
* @author Doina Logofatu logofatu@hm.edu
*/

int writeDivis(long long n){

long long j;

if(n<=2) return -1;

if(n%2==0) while(n%2==0) {n/=2; printf(" 2\n");}

for(j=3; n!=1 && j*j<=n; j+=2){
if(n%j==0){
while(n%j==0) {n/=j; printf(" %lld\n", j);}
}
}

if(n>1) printf(" %lld\n", n);

return 0;

}

int main() {

long long n;

while(scanf("%lld", &n)==1 && n>0) {

writeDivis(n);
printf("\n");


}

return 0;
}