to find the divisors of a number and to add all the divisors to check whether it is greater than the given number

AnswerBot
1y

The program finds the divisors of a number and checks if their sum is greater than the given number.

  • Iterate from 1 to the given number

  • Check if the number is divisible by the current iteration value

  • If ...read more

Anonymous
1y

import java.util.Scanner;

public class Main {

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

int sum = 0;

System.out.print("Enter the number: ");

int n = scanner.nextInt();

for (int i = 1; i < n; i++) {

if (n % i == 0) {

sum += i;

}

}

if (sum < n) {

System.out.println("The sum of divisors is less than the given number");

} else {

System.out.println("The sum of divisors is greater than the given number");

}

}

}

PALANISAMY M
1y

sum=0

n=input("enter the number")

for i in range(n):

if n%i==0:

sum+=i

if sum

print("the sum of divisors is less than the given number")

else:

print("the sum of divisors is greater than the given numbe...read more

Balaji
3y

//to find the divisors of a number and to add all the divisors to check whether it is greater than the given number #include #include using namespace std; int main() { int n; cin >...read more

Add answer anonymously...
Zoho Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter