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 #1: Multiples of 3 and 5
  4. Discussions

Project Euler #1: Multiples of 3 and 5

Contest ends in
Problem
Submissions
Leaderboard
Discussions

    You are viewing a single comment's thread. Return to all comments →

  • sahilchandel4200
    1 year ago+ 2 comments

    or anyone who is using Python3. If you've already converted from the iterive to the O(1) solution but you're still getting the "wrong answer" with Test Cases 2 and 3 here is why: When you divide integers in python 3, the answer is converted automatically to a float. Becuase Test Cases 2 and 3 involve very large numbers, when you convert back to integer, there will be a huge rounding error and your answers will be wrong. so rather than dividing with 2 or multiplying by 0.5 just do right shift by 1.

    4|
    Permalink
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy