Código:
1.// Devuelve la mayor de las cifras de [n] cuandp [n] se escribe en base 10 public static int cifraMayor (int n) { int resto = 0; int mayor = 0; while (n!=0) { resto = n%10; if (resto > mayor)mayor=resto; n= n/10; } return mayor; }
Código:
2.// Devuelve el mayor de los valores de [a] y [b] public static int mayor (int a, int b) { int mayor=0; if (a>b){ mayor = a; }else{ mayor = b; } return mayor; }
Código:
3.// Devuelve el mayor de los valores de [a], [b] y [c] public static int mayor (int a, int b, int c) { int mayor=0; if (a>b) { mayor = a; }else{ mayor=b; } if (c > mayor){ mayor =c; } return mayor; }
Código:
4.private static final String romanos[] = {"I","II","III","IV","V","VI","VII","VIII","IX"}; public static String romanizarCifra (int cifra) { if (cifra>0 && cifra<=9) return romanos[cifra-1]; else return null; }
Código:
Gracias ;) 5.public static boolean sonPrimosEntreSi (int a, int b) { if(a<0) a=-a; if(b<0) b=-b; while (b!=0) { int resto = a%b; a=b; b=resto; } if (a==1) { return true; } else { return false; }