#!/usr/bin/bc /* fizzbuzz.bc * A little program that plays extreme fizzbuzz with itself. * (c) 2013 D. Haworth */ define contains(x,n) { y = x; while ( y > 0 ) { r = y%10; if ( r == n ) { return 1; } y = y/10; } return 0; } n=1 /* while (n <= 500) */ while (1) { if ( ((n % 3) == 0) || contains(n,3) ) { if ( ((n % 5) == 0) || contains(n,5) ) { print "FizzBuzz\n" } else { print "Fizz\n" } } else { if ( ((n % 5) == 0) || contains(n,5) ) { print "Buzz\n" } else { print n, "\n" } } n+=1 }