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
  • Practice
  • Certification
  • Compete
  • Career Fair
  • Hiring developers?
  1. All Contests
  2. ProjectEuler+
  3. Project Euler #45: Triangular, pentagonal, and hexagonal

Project Euler #45: Triangular, pentagonal, and hexagonal

Problem
Submissions
Leaderboard
Discussions

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

Triangle, pentagonal, and hexagonal numbers are generated by the following formulae:

It can be verified that

For this challenge you are given , , , where and
where represents triangular numbers, represents pentagonal numbers and is hexagonal. It can be observed that all hexagonal numbers are triangular numbers so we'll handle only 2 kinds of queries as
, find all numbers below N which are Triangular number as well as Pentagonal
, find all numbers below N which are Pentagonal number as well as Hexagonal

Input Format
Input contains three integers

Output Format
Print the answer corresponding to the test case. Print numbers in ascending oder.

Constraints


Sample Input #00

10000 3 5

Sample Output #00

1
210

Sample Input #01

100000 5 6

Sample Output #01

1
40755

Author

shashank21j

Difficulty

Easy

Max Score

100

Submitted By

1497

Need Help?


View discussions
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits

Choose a translation


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