## Class PE0061

• All Implemented Interfaces:
`Solvable`

```public class PE0061
extends Problem```
Solution for problem 61 "Cyclical figurate numbers" completed on Thu, 21 Mar 2019, 22:49.
Since:
06.05.2018 08:14:33
Author:
Nico Danneberg
Problem @ Project Euler, Solution @ Ni-Da-Net
• ### Field Summary

Fields
Modifier and Type Field Description
`private java.util.Vector<java.util.ArrayList<java.lang.Integer>>` `mem`
Memory for all Triangle, Square, Pentagonal, Hexagonal, Heptagonal, and Octagonal numbers with 4 digits.
• ### Fields inherited from class net.n1da.dev.euler.core.Problem

`number, title`
• ### Method Summary

Modifier and Type Method Description
`private boolean` ```check​(int a, int b)```
Checks if the given numbers follow each other.
`private int` `find()`
Starts the recursion by testing every Triangle number.
`private int` ```find​(int level, int used, int first, int current)```
Tries to find a number that follows the given current number.
`void` `prepare()`
All 4 digit numbers are calculated and stored in the `memory attribute`.
`java.lang.String` `solve()`
This method solves the problem bei calling `find()` method as starting point of recursion.
• ### Methods inherited from class net.n1da.dev.euler.core.Problem

`finish, getResult, getRuntime, toString`
• ### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`
• ### Field Detail

• #### mem

`private java.util.Vector<java.util.ArrayList<java.lang.Integer>> mem`
Memory for all Triangle, Square, Pentagonal, Hexagonal, Heptagonal, and Octagonal numbers with 4 digits.
• ### Method Detail

• #### prepare

`public void prepare()`
All 4 digit numbers are calculated and stored in the `memory attribute`.
Specified by:
`prepare` in interface `Solvable`
Overrides:
`prepare` in class `Problem`
• #### solve

`public java.lang.String solve()`
This method solves the problem bei calling `find()` method as starting point of recursion.
Returns:
sum of the found six cyclic numbers
• #### find

`private int find()`
Starts the recursion by testing every Triangle number.
Returns:
the found sum of the six cyclic numbers
• #### find

```private int find​(int level,
int used,
int first,
int current)```
Tries to find a number that follows the given current number. If it finds such a number it calls itself recursively with a higher level. If level 6 is reached it checks if the current number can have the first number as follower.
Parameters:
`level` - the current level
`used` - a binary number that stores all used figurate levels
`first` - the very first number (a Triangle)
`current` - the current number
Returns:
the sum of all cyclic number to the current level
• #### check

```private boolean check​(int a,
int b)```
Checks if the given numbers follow each other.
Parameters:
`a` - the previous number
`b` - the follower
Returns:
true if the last two digits of a are equal to the first two digits of b