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
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. All Contests
  2. ProjectEuler+
  3. Project Euler #245: Coresilience

Project Euler #245: Coresilience

Problem
Submissions
Leaderboard
Discussions
  1. All Contests
  2. ProjectEuler+
  3. Project Euler #245: Coresilience
Exit Full Screen View
  • Problem
  • Submissions
  • Leaderboard
  • Discussions

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

We shall call a fraction that cannot be cancelled down a resilient fraction.

Furthermore we shall define the resilience of a denominator, , to be the ratio of its proper fractions that are resilient; for example, consider . The proper fractions with a denominator are . Four of these cannot be cancelled down, so the resilience is .

The resilience of a number is then

where φ is Euler's totient function.

We further define the coresilience of a number as

Given an integer , find the sum of all integers for which is a unit fraction, that is, a fraction with a numerator of after cancelling down.

Input Format

Each test file contains a single line containing a single integer .

Constraints

Output Format

Print the integer value of the sum of all integers for which is a unit fraction.

Sample Input 0

5

Sample Output 0

10

Explanation 0

Integer 2 3 4 5
Euler Phi 1 2 2 4
Coresilience 1/1 1/2 2/3 1/4



The sum of integers with Coresilience a unit fraction:   .

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