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.
"The square root of two is 1.41421356237309504880..., and the digital sum of the first one hundred decimal digits is 475."
The explanation can be clearer, its not first one hundred decimal digits but first one hundred digits. Decimal digits starts after the decimal point. But the answer counts all digits including the one before decimal point.
Also, set precision to higher than P, then truncate, e.g. P = 100, set precision to 110, then truncate the last 10 digits.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #80: Square root digital expansion
You are viewing a single comment's thread. Return to all comments →
"The square root of two is 1.41421356237309504880..., and the digital sum of the first one hundred decimal digits is 475."
The explanation can be clearer, its not first one hundred decimal digits but first one hundred digits. Decimal digits starts after the decimal point. But the answer counts all digits including the one before decimal point.
Also, set precision to higher than P, then truncate, e.g. P = 100, set precision to 110, then truncate the last 10 digits.