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.
I have been getting wrong answers for last 2 cases. Figured out that mistake was during casting to long. If you are using Java, casting a big Double value(> 2^52) will lose precision so always use it like :
new Double(WHATEVER).longValue()
For others one usecase to try :
1
9999999999999995 999999999934999995 999992599999999996 999991999999998 999999999999999999 999123999999999999 1000000000000000000
Output :
370440
Explanation :
7 * 7 * 8 * 7 * 5 * 9 * 3
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #40: Champernowne's constant
You are viewing a single comment's thread. Return to all comments →
I have been getting wrong answers for last 2 cases. Figured out that mistake was during casting to long. If you are using Java, casting a big Double value(> 2^52) will lose precision so always use it like : new Double(WHATEVER).longValue()
For others one usecase to try : 1 9999999999999995 999999999934999995 999992599999999996 999991999999998 999999999999999999 999123999999999999 1000000000000000000
Output : 370440
Explanation : 7 * 7 * 8 * 7 * 5 * 9 * 3