public class RelativamentePrimo { public static void main(String[] args) { if (args.length < 1) { System.out.println("Errore: devi fornire un numeri intero come argomento."); return; } int numero = Integer.parseInt(args[0]); for (int i = 1; i <= numero; i++) { for (int j = 1; j <= numero; j++) { if (gcd(i, j) == 1) { System.out.print("* "); } else { System.out.print(" "); } } System.out.println(); } } // Metodo per calcolare il massimo comun divisore (Euclide) public static int gcd(int a, int b) { while (b != 0) { int temp = b; b = a % b; a = temp; } return a; } }