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
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. All Contests
  2. ProjectEuler+
  3. Project Euler #61: Cyclical figurate numbers

Project Euler #61: Cyclical figurate numbers

Problem
Submissions
Leaderboard
Discussions

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

Triangle, square, pentagonal, hexagonal, heptagonal, and octagonal numbers are all figurate (polygonal) numbers and are generated by the following formulae:

The ordered set of three 4-digit numbers: 8128, 2882, 8281, has three interesting properties.

  • The set is cyclic, in that the last two digits of each number is the first two digits of the next number (including the last number with the first).

  • Each polygonal type: triangle , square , and pentagonal , is represented by a different number in the set.

  • This is the only set of 4-digit numbers with this property.

You are given a set of numbers find the sum of numbers from sets that respect the above property. If there are multiple such numbers print their sums in sorted order.

Input Format

First line of input contains a number T.
Second line contains set of numbers each separated by a space.

Constraints

Output Format

Print the answer corresponding to the test case.

Sample Input

3
3 4 5

Sample Output

19291

Author

shashank21j

Difficulty

Easy

Max Score

100

Submitted By

1405

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