Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- System.out.println("Введите натуральное число: ");
- Scanner sc = new Scanner(System.in);
- int num = sc.nextInt();
- if (num % 2 != 0 && num % 3 != 0 && num % 4 != 0 && num % 5 != 0 && num % 6 != 0 && num % 7 != 0 && num % 8 != 0 && num % 9 != 0) {
- System.out.printf("Ваше число %d простое. ", num);
- } else {
- for (int x = 1; x < num; x++) {
- if (num % x == 0) {
- System.out.printf("Выбранное число делится на %d\n", x);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment