Computer Science, asked by sruthi7769, 1 month ago

A number that is smaller than the sum of its factors excluding the

highest factor is said to be an Abundant Number.

Example: Number=12

Sum of its factors excluding the highest

factor=1+2+3+4+6=16

Write a program to print all abundant numbers in the range 1 to n(both

inclusive) where n is to be accepted in the program.print the output with the

appropriate message​

Answers

Answered by SabrinaHaque
0

#include<iostream>

using namespace std;

int main()

{

int range1,range2;

cout<<"Enter a range:";

cin>>range1>>range2;

cout<<"Abundant numbers between "<<range1<<" and "<<range2<<" are: ";

for(int j=range1;j<=range2;j++)

{

int sum=0;

for(int i=1;i<j;i++)

{

if(j%i==0)

{

sum=sum+i;

}

}

if(sum>j)

cout<<j<<" ";

}

}

Similar questions