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.
  • Practice
  • Certification
  • Compete
  • Career Fair
  • Hiring developers?
  1. All Contests
  2. ProjectEuler+
  3. Project Euler #44: Pentagon numbers
  4. Discussions

Project Euler #44: Pentagon numbers

Problem
Submissions
Leaderboard
Discussions

Sort 31 Discussions, By:

votes

Please Login in order to post a comment

  • [deleted] 5 years ago+ 0 comments

    I guess we're not allowing negative values of n for P_n = n * (3n - 1)? Otherwise, the answer to the test case would also include 117, since P_-11 = 187 = 117 + 70 = P_9 + P_7.

    3|
    Permalink
  • acossack 2 years ago+ 0 comments

    Output Format: Print the pentagonal numbers corresponding to the test case in sorted order, each in a new line.

    Формат выходных данных: Вывести пятиугольные числа для заданного теста через пробел.

    Russian version is wrong.

    2|
    Permalink
  • byungwoo 3 years ago+ 0 comments

    Test Case #3 - Must remove duplicate values.

    1|
    Permalink
  • cnhnyu 4 years ago+ 0 comments

    If you are using C++, make sure you are using long for all data type. Mixing long and int will give your wrong results.

    The maximum number is 10^6, you can just build a Pentagon numbers map from 1 to 10^6. Then to test if Pn - Pn-k or Pn - Pn+k in this map, if either of them in the map, just print Pn.

    After you build this map, you can get the results in O(1) time complexity.

    1|
    Permalink
  • god_blessme 4 years ago+ 0 comments

    For everybody who are struggling with timeout problem.Dont go through the loop to check whether a given number is pentagonal number.Just check,

    n=(sqrt(24*x+1)+1)/6; if x is a pentagonal number then n should be a natural number.

    Hope this helps!!!

    1|
    Permalink
Load more conversations

Need Help?


View top submissions
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature