Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int sum( int n ){
- int sum = 0;
- for( int i = 2 ; i <= sqrt( n ) ; i++ ){
- if( !( n % i ) ) sum += i + n / i;
- }
- return sum + 1;
- }
- int main(){
- int t;
- cin >> t;
- while( t-- ){
- int n;
- cin >> n;
- if( n == sum( n ) ) cout << n << ' ';
- }
- puts("");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement