Show the (decimal) value of a number of 1s appended with a 3, then squared: Difference between revisions

→‎AWK: simplify
No edit summary
(→‎AWK: simplify)
Line 155:
=={{header|AWK}}==
<syntaxhighlight lang="awk">
# syntax: GAWK -f SHOW_THE_DECIMAL_VALUE_OF_A_NUMBER_OF_1S_APPENDED_WITH_A_3_THEN_SQUARED.AWK
# converted from FreeBASIC
BEGIN {
form (i=0; i<=7; i++) {2
for (n m= 0; n != make13(i8; ++n) {
printf("%1d %9s^2 %'20d\n",i,m, = m *m) 10 - 17
printf "%u %9u^2 %'20u\n", n, m, m * m
}
exit(0)
}
function make13(n, t) {
while (n--) {
t = 10 * (t+1)
}
return(t+3)
}
</syntaxhighlight>
559

edits