NLKappa

Homework 28.09

Sep 27th, 2017
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7.     public static void main(String[] args) {
  8.         System.out.println("Введите натуральное число: ");
  9.         Scanner sc = new Scanner(System.in);
  10.         int num = sc.nextInt();
  11.         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) {
  12.             System.out.printf("Ваше число %d простое. ", num);
  13.         } else {
  14.             for (int x = 1; x < num; x++) {
  15.                 if (num % x == 0) {
  16.                     System.out.printf("Выбранное число делится на %d\n", x);
  17.                 }
  18.             }
  19.  
  20.         }
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment