finished prime number generator and capacity function