I'd divide $total_nums by 30 and check the remainder.
In reply to Re: condensing code by chromatic in thread condensing code by Anonymous Monk