Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company.hw3;
- import java.util.Scanner;
- public class task3 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int x, res = 0;
- x = scanner.nextInt();
- for (int i = 2; i <= x; i++) {
- if (x % i == 0) {
- int div_count = 0;
- for (int j = 2; j < i; j++) {
- if (i % j == 0) {
- div_count += 1;
- }
- }
- if (div_count == 0) {
- res += i;
- }
- }
- }
- System.out.println(res);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement