the formula is actually very simple.
It is the product of the number of entries for each slot.
For example PA dialy number uses three balls each with the available numbers being 0 - 9.
So all combinations is 10 10 10 = 1000
Pennsylvania Cash 5 uses 1 - 39 and 5 balls are selected but a given number cannot be repeated so the total available combinations are 39 38 37 36 35 = 690,908,40
If what you want to know is how to calculate these totals dynamically for different games it is pretty simple.
Step 1) Calculate the range of numbers by taking (high - low) + 1.
Step 2) If you have a static range (i.e. PA daily number) proceed to step 3, else proceed to step 4.
Step 3)
<?php
$total = $range;
for($i=1;$i<$balls;$i++)
$total *= $range;
?>
Proceed to step 5
Step 4)
<?php
$total = $range;
for($i=1;$i<$balls;$i++)
$total = $total * ($range - $i);
?>
Step 5)
<?php
echo 'There are ' . $total . ' combinations for this lottery.';
?>
Two more exercised remain that are left to the reader.
Exercise 1: PA Daily number allows you to play boxed and straight. The above code calculates the number of straight possibilies (i.e. 123 != 321) however it does not calculate the number of boxed possibilities (i.e. 123 == 321).
Exercise 2: Some lotteries choose some balls from one pool and some balls from another pool. This means that their range schema does not fit into either of the above coded categories.