Docsity

código de java import, Guías, Proyectos, Investigaciones de Literatura Latina

Toggle sidebar
bg1
import java.io.*;
public class FORO1{
public static void main(String[]args) throws IOException{
BufferedReader br=new BufferedReader (new InputStreamReader(System.in));
int N,SD=0,C;
do{
System.out.print("Ingrese el número: ");
N=Integer.parseInt(br.readLine());
}while(N<=0);
for(C=1;C<N;C=C+1){
if(N%C==0){
SD=SD+C;
}
}
if(N==SD){
System.out.print("El número es perfecto.");
}else{
System.out.print("El número no es perfecto.");
}
}
}

Vista previa parcial del texto

¡Descarga código de java import y más Guías, Proyectos, Investigaciones en PDF de Literatura Latina solo en Docsity!

import java.io.*; public class FORO1{ public static void main(String[]args) throws IOException{ BufferedReader br=new BufferedReader (new InputStreamReader(System.in)); int N,SD=0,C; do{ System.out.print("Ingrese el número: "); N=Integer.parseInt(br.readLine()); }while(N<=0); for(C=1;C<N;C=C+1){ if(N%C==0){ SD=SD+C; } } if(N==SD){ System.out.print("El número es perfecto."); }else{ System.out.print("El número no es perfecto."); } } }