Advertisement
Guest User

Untitled

a guest
Jul 12th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement