Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Day4Problem1
- {
- public static void main(){
- int count = 0;
- for(int i = 178416; i <= 676561; i++){
- if(checkNum(i))
- count++;
- }
- System.out.println(count);
- }
- public static boolean checkNum(int n){
- boolean hasDouble = false;
- int current;
- int next;
- while(n > 0){
- current = n%10;
- n /= 10;
- next = n%10;
- if(next > current)
- return false;
- else if(current == next)
- hasDouble = true;
- }
- return hasDouble;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement