Pagini recente » Cod sursa (job #2926512) | Cod sursa (job #1976936) | Cod sursa (job #1976929) | Cod sursa (job #2297866) | Cod sursa (job #2216698)
package ciur;
import java.io.*;
import java.util.*;
import java.lang.*;
public class Ciur {
public Scanner x;
String a = "";
int n;
int nr = 0;
boolean b ;
public void openFile(){
try{
x = new Scanner(new File("C:\\numar.txt"));
}catch(Exception e){
System.out.println("nu exista fisierul!");
}
}
public void readFile(){
while(x.hasNext()){
a = x.next();
}
n = Integer.parseInt(a);
}
public void closeFile(){
x.close();
}
public int ciur(){
for(int i = 2 ; i <= n ; i++){
b = true;
for (int j = 2 ; j <= n ; j++){
if ((i % j == 0) && (i != j)){
b = false;
break;
}
if (b == false){
break;
}
}
if(b == true){
nr = nr + 1;
}
}
return nr;
}
}