This program is very simple. It does a lot of work in vain. Nevertheless the first 1000 terms can be calculated in 5 seconds. With an advanced program millions of terms are available. Integer n // order of the polyiamond a, b, c // side lengths of the polyiamond nx = 1000 // number of terms for the sequence PS(1 To nx) // pentagonal polyiamond sequence sum = 0 // sum of the first n terms For c = 1 To nx For a = c + 1 To nx - c For b = a - c + 1 To nx // Type A n = 2 * b * c + (a - c) ^ 2 If n <= nx Then PS(n)++ For b = a + 1 To nx // Type B n = 2 * (b - a) * c + a * a If n <= nx Then PS(n)++ For a = c To nx - c For b = a + 1 To a + c - 1 // Type C n = b * b - 2 * (b - a) * (b - c) If n <= nx Then PS(n)++ For b = 1 To nx // Type D n = 2 * (b + a) * (b + c) - b * b If n <= nx Then PS(n)++ For n = 1 To nx sum = sum + PS(n) Print n, PS(n), sum