CodeSnippet:
import java.util.Scanner; import java.util.ArrayList; public class Scheiss { /** * @param args the command line arguments */ public static void main (String[] args ) { System. out. println("Bitte Primzahl eingeben"); Scanner intReader = new Scanner (System. in); int intPrime = intReader.nextInt(); System. out. println("Bitte a-Wert eingeben"); int intA = intReader.nextInt(); int ordnung = getOrdnung(intPrime,intA); System. out. println("Die Ordnung lautet " + ordnung ); if(ordnung==(intPrime-1)) { System. out. println("ist primitiv"); } else { System. out. println("ist nicht primitiv"); } intReader.close(); } public static int getOrdnung(int intPrime,int intA) { int count = 1; int current_result = intA; while(current_result!=1) { current_result = (intA * current_result) % intPrime; count++; } return count; } }
|