FizzBuzz/AWK: Difference between revisions

m
no edit summary
mNo edit summary
Line 71:
<lang AWK># usage: awk -v n=38 -f fizzbuzzNoDiv.awk
#
# FizzBuzz using no division & no modulo - operations:
BEGIN {
if(!n) n=100
Line 91:
 
This is inspired by the versions "Without Modulus" of Nimrod and Python, <br>
using a precomputed/ (observed:) pattern to decide how to print each number. <br>
But here, the pattern is represented as chars in a string, instead of bits in an integer.
instead of bits in an integer.
<lang AWK># usage: awk -v n=42 -f fizzbuzzRepeatPattern.awk
#
Line 108 ⟶ 109:
while (i<n) {
i++; sel++;
prt(i, substr(pattern,sel,1) ); # select which variant to use from the pattern
if( sel>length(pattern)) {) sel=1; }
}
print "\n# Done."
Anonymous user