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 #92: Square digit chains

Project Euler #92: Square digit chains

Problem
Submissions
Leaderboard
Discussions

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

A number chain is created by continuously adding the square of the digits in a number to form a new number until it has been seen before.

For example,


Therefore any chain that arrives at or will become stuck in an endless loop. What is most amazing is that EVERY starting number will eventually arrive at or .

How many starting numbers below will arrive at ? As the result can be large, print modulo

Input Format

First and only line contains .

Constraints

Output Format

Print the required answer.

Sample Input

1

Sample Output

7

Author

shashank21j

Difficulty

Easy

Max Score

100

Submitted By

1243

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