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.
Here's how I approached the problem.( I used Java ) First I scanned akk the numbers and checked using modulus. This gave me a time out error. Then I used the sum of arithmatic progression formula, which got past the tine out error , but gave me a wrong answer error. This was because, the sums generated in test case 3 and 4 results were out of range of the long number's range. So, I used the BigInteger for sums and long for inputs. And finally the solution worked.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #1: Multiples of 3 and 5
You are viewing a single comment's thread. Return to all comments →
Here's how I approached the problem.( I used Java ) First I scanned akk the numbers and checked using modulus. This gave me a time out error. Then I used the sum of arithmatic progression formula, which got past the tine out error , but gave me a wrong answer error. This was because, the sums generated in test case 3 and 4 results were out of range of the long number's range. So, I used the BigInteger for sums and long for inputs. And finally the solution worked.