Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class preverjanje {
- public static void main(String[] args) {
- int zacetek = 10000000;
- int konec = 99999999;
- while(zacetek <= konec)
- {
- if(check(zacetek))
- {
- System.out.println(zacetek);
- }
- zacetek++;
- }
- }
- public static boolean check(int stevilka)
- {
- boolean pravilnost = false;
- char[] cifre = ("" + stevilka).toCharArray();
- int vsota = 0;
- int n = 8;
- for(int i =0; i < cifre.length-1;i++)
- {
- int a = Character.digit(cifre[i],10);
- vsota = vsota + (n*a);
- n--;
- }
- int mod = vsota % 11;
- int ostanek = 11-mod;
- if(ostanek == 10)
- {
- ostanek=1;
- }
- int last = Character.digit(cifre[7], 10);
- if(last==ostanek)
- {
- pravilnost=true;
- }
- return pravilnost;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement