
public class Primes7 {
 static long primzahl;
 static long count2;
 static long[] primfeld;
 static long erg = 1;
 static long eing;
public static void main (String[] args)  {
	System.out.println("Primfaktorzerlegung von positiven natuerlichen Zahlen !");
	if (args.length == 0){args[0] = GetInput();}

	for (int a=0; a < args.length; a++){
          erg=1;count2=1;
    	  System.out.print(args[a] + " = ");
          eing = Long.parseLong(args[a]);
          
          Prim(Long.parseLong(args[a]));
    	}
 
}

//------Methode gets Input------
public static String GetInput(){
            System.out.print("Geben Sie eine Zahl ein : ");
           String b = Keyboard.readString();
          return b;
 }  

//----Brechnet die Primzahlen----
public static void getPrim(long start){
int i=2;
 
  
     while((start % i != 0)&&(i<start)){i++;}
        if(i==start){primzahl = start;}
      	   else {count2++;getPrim(count2);}
}

//----Methode zum Rechnen und Ausgeben-----
public static void Prim(long zahl){
 if (zahl>1){ 
       getPrim(count2);
         if (primzahl == zahl){System.out.println(zahl);}  
          else
              if (zahl%primzahl == 0){
                           System.out.print(primzahl + " * ");
			   if(primzahl>0)
                           zahl = zahl/primzahl;                                                                 
              }
          else
            if(zahl%primzahl != 0){System.out.prin("prim");getPrim(count2); count2=count2+1;}  
        erg = erg*primzahl;
        if (erg != eing) Prim(zahl);  	
        
    
  }

}//--End of Prim----

}//---End of Application