public class NumeroDeficienteAbundantePerfecto {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Introduce numero: ");
int numero = sc.nextInt();
int suma = 0;
System.out.print("DIVISORES: ");
for (int i = 1; i < numero; i++){
if ( numero%i == 0){
System.out.print(i+" ");
suma+=i;
}
}
System.out.println("\n Suma de sus divisores: "+suma);
System.out.print("el numero "+numero+" es: ");
if (suma < numero) System.out.print("deficiente");
if (suma > numero) System.out.print("abundante");
if (suma == numero) System.out.print("perfecto");
}
}
NumeroDeficienteAbundantePerfecto
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.