getGenerations function

Count Generations