I think I would like to structure this so that getPentagonalNumber(int n)
n
pentagonal number - just calculating one at a time. This makes it easy to understand and verify. Worry about compiling their list in the main
function, which can call your getPentagonalNumber
function.
You might want your main function storage results to be in a List
. When the list is .size() == 10
, call printResults(theResultList)
(which you will write using some code currently in main
) and .clear()
list. Especially when you get started, small functions and clearly defined responsibilities will help you keep track of what your code is doing.
source share