Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Demo2 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = scanner.nextInt();
- for (int i = 1; i <= n; i++) {
- boolean isOdd = false;
- int sum = 0;
- int num = i;
- for (int e = 0; e < i; e++) {
- sum += num % 10;
- num /= 10;
- if (num % 2 != 0) {
- isOdd = true;
- }
- }
- if (sum % 8 == 0 && isOdd) {
- System.out.println(i);
- // } else {
- // System.out.printf("%d -> False\n", i);
- // }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement