Computer Science, asked by bhanusri5a0, 9 months ago

Perfect numbers in the range Write a program to find the perfect numbers between a given range. Input Format: The first input contains an integer which denotes the starting number of the range The second input contains an integer which denotes the ending number of the range

Answers

Answered by jneetu334
0

Answer:

Perfect numbers in the range

Write a program to find the perfect numbers between a given range.

Input Format:

The first input contains an integer which denotes the starting number of the range

The second input contains an integer which denotes the ending number of the range

Output Format:

Print the perfect numbers in a given range

Sample Input:

1

10

Sample Output:

6

Answered by gauravfeel
0

Answer:

#include<iostream>

main()

{

int n1,n2,p=0;

std::cin>>n1>>n2;

for(int i=n1;i<=n2;i++)

{

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

  {

    if(i%j==0)

      p+=j;

    else

      p+=0;

  }

  if(p==i)

  {

    std::cout<<p<<" ";

    p*=0;

  }

  else

    p*=0;

}

}

Explanation:

Similar questions