daily pastebin goal
77%
SHARE
TWEET

Untitled

a guest Jul 12th, 2018 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2. public class Main {
  3.     public static void main(String[] args) {
  4.         Scanner input = new Scanner(System.in);
  5.         int n = input.nextInt();
  6.         int i , j , sum;
  7.         for( i = 2 ; i <= n ; i++ )
  8.         {
  9.             sum = 0 ;
  10.             for( j = 1 ; j < i ; j++ )
  11.             {
  12.                 if( i % j == 0 )
  13.                 {
  14.                     sum += j ;
  15.                 }
  16.             }
  17.             if( i == sum )
  18.             {
  19.                 System.out.print( i + "\n" ) ;
  20.             }
  21.         }
  22.     }
  23. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top