
como imprimir mi programa de numeros primos en un txt
Publicado por eduardo martinez (3 intervenciones) el 11/03/2016 05:01:04
hola que tal a todos,necesito de su ayuda por favor,necesito saber como imprimir el resultado de mi programa en un txt. Tambien comento que lo hice con scanner pero si alguien puede decirme como leer los valores valores desde un txt e imprimir el resultado en txt se lo agradeceria mucho,dejor el codigo :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
public static boolean Primo (int num) {
boolean Primo = true;
int division = 2;
while ((Primo)&& (division!=num))
if (num%division==0){
Primo = false;
} else{
division++;
}
return Primo;
}
public static void main(String[] args)
{
// int i;
// Scanner leer= new Scanner(System.in);
// System.out.println("introduzca un numero menor a 50:");
// i = leer.nextInt();
boolean Primo;
for(int i = 2; i<=50; i++){
Primo = Primo(i);
if(Primo==true){
System.out.println(i+" Es Primo");
}else{
System.out.println(i+" No es Primo");
}
}
}
Valora esta pregunta


0