We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. All Contests
  2. ProjectEuler+
  3. Project Euler #21: Amicable numbers

Project Euler #21: Amicable numbers

Problem
Submissions
Leaderboard
Discussions

This problem is a programming version of Problem 21 from projecteuler.net

Let be defined as the sum of proper divisors of (numbers less than which divide evenly into ).
If and , where , then and are an amicable pair and each of and are called amicable numbers.

For example, the proper divisors of are therefore . The proper divisors of are so .

Evaluate the sum of all the amicable numbers under .

Input Format

The first line contains an integer , i.e., number of test cases.
Next lines will contain an integer .

Constraints

Output Format

Print the values corresponding to each test case.

Sample Input

1
300

Sample Output

504

Explanation

Under we only have and , sum is

Author

shashank21j

Difficulty

Easy

Max Score

100

Submitted By

6732

Need Help?


View discussions
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits

Choose a translation


  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy