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
  • Apply
  • Hiring developers?
  1. All Contests
  2. ProjectEuler+
  3. Project Euler #44: Pentagon numbers

Project Euler #44: Pentagon numbers

Contest ends in
Problem
Submissions
Leaderboard
Discussions

This problem is a programming version of Problem 44 from projecteuler.net

Pentagonal numbers are generated by the formula, . The first ten pentagonal numbers are:

It can be seen that . Also is also pentagonal.

Generalizing for a given find all such that is pentagonal or is pentagonal.

Input Format

Input contains two integers and separated by space.

Constraints


Output Format

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

Sample Input

10 2

Sample Output

70

Author

shashank21j

Difficulty

Easy

Max Score

100

Submitted By

3118

Need Help?


View discussions
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits

Choose a translation


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