# BC program devised by Alan Offer on 28th December 2011.
# "Increment" the list of exponents in b[] subject to being bounded by a[]
define next(*b[], a[], t) {
auto i
i = t - 1
while ( i >= 0 ) {
b[i] += 1
if ( b[i] > a[i] ) {
b[i] = 0
i -= 1
} else {
return 0
}
}
# Return "true" when cycle around to all b[j]=0.
return 1
}
# Example usage of "next". List exponents for divisors.
define exps(a[], t) {
auto i, finished, count, b[]
finished = 0
count = 0
while ( !finished ) {
for (i=0; i