100% Guaranteed Results


Project
$ 29.99
Category:

Description

5/5 – (1 vote)

This problem is a programming version of Problem 44 from projecteuler.net
Pentagonal numbers are generated by the formula, Pn = n(3n − 1)/2. The first ten pentagonal numbers are:
1,5,12,22,35,51,70,92,117,145,⋯
It can be seen that P4 + P7 = 22 + 70 = 92 = P8. Also P7 − P5 = 70 − 35 = 35 = P5 is also pentagonal.
Generalizing for a given K find all Pn,(n < N) such that Pn − Pn−K is pentagonal or Pn + Pn−K is pentagonal.
Input Format
Input contains two integers N and K separated by space.
Output Format
Print the pentagonal numbers corresponding to the test case, each in a new line.
Constraints
1 ≤ K ≤ 9999
6
K + 1 ≤ N ≤ 10
Sample Input

Sample Output

Reviews

There are no reviews yet.

Be the first to review “Project”

Your email address will not be published. Required fields are marked *

Related products