-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem21.cpp
More file actions
36 lines (36 loc) · 738 Bytes
/
Copy pathproblem21.cpp
File metadata and controls
36 lines (36 loc) · 738 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
bool abundant(int n){
int sum=0;
for(int i=1; i<=sqrt(n); i++){
if(n%i==0){
if(n/i==i){
sum+=i;
}
else {
int s1 = i + n/i;
sum+=s1;
}
}
}
sum = sum-n;
if (sum>n) return true;
else return false;
}
int main() {
vector <int> A;
long long sum = 0 , sum1 = 0;
for (int i=1; i<=28123; i++){
int n1 = abundant(i);
if(n1==0){
sum+=i;
//cout<<i<<endl;
}
if(n1==1){
sum1 +=i;
cout<<i<<endl;
}
}
cout<<endl<<sum1;//cout<<"Hello World!";
}