program to calculate num samples