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 #159: Digital root sums of factorisations.

Project Euler #159: Digital root sums of factorisations.

Problem
Submissions
Leaderboard
Discussions

This problem is a programming version of Problem 159 from projecteuler.net
A composite number can be factored many different ways.
For instance, not including multiplication by one, can be factored in distinct ways:







Recall that the digital root of a number, in base , is found by adding together the digits of that number, and repeating that process until a number is arrived at that is less than .
Thus the digital root of is .

We shall call a Digital Root Sum () the sum of the digital roots of the individual factors of our number.

The chart below demonstrates all of the values for .

The maximum Digital Root Sum of is .

The function gives the maximum Digital Root Sum of . So .

Find .

Input Format

First line of each file contains an integer which is the number of testcases.
lines follow, each containing one integer .

Constraints

Output Format

Output lines, one for each testcase.

Sample Input

1
10

Sample Output

51

Explanation









Author

bayleef

Difficulty

Medium

Max Score

100

Submitted By

617

Need Help?


View discussions
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy