Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int divisor(int n){
- int sum = 0;
- for(int i = 1; i < n; i++){
- if(n%i==0) sum += i;
- }
- if(sum == n) return 1;
- else return 0;
- }
- main(){
- int a, b, check = 0;
- cin>>a>>b;
- for(int i = a; i <= b; i++){
- if(divisor(i)) {
- check = 1;
- cout<<i<<' ';
- }
- }
- if(check == 0) cout<<"0";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement