Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Prvocislo {
- public static void main(String[] args) {
- int maximum = 1564;
- int i;
- for(i = maximum ; i>0; i++) {
- if(jePrvocislo(i) && neopakujeSe(i)) {
- break;
- }
- }
- System.out.println("Hledane cislo je "+i);
- }
- public static boolean jePrvocislo(int x) {
- for(int i = 2; i<x; i++) {
- if(x%i==0) return false;
- }
- return true;
- }
- public static boolean neopakujeSe(int x) {
- char[] cislice = String.valueOf(x).toCharArray();
- for(int i = 1; i<cislice.length; i++) {
- for(int j = 0; j<i; j++) {
- if(cislice[i]==cislice[j]) return false;
- }
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement