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1,2,1,4,2,3,
3,0,2,3,4,2,4,1,2,4,4,1,

\$ cat recalc
#!/bin/sh

nl='
'

run() {
echo "\$1 sqrt(\$2) base \$3"
echo "BC:"
echo "val=\$2; scale=100; obase=\$3; ibase=\$3; sqrt(val)" |
bc -l -q |
tr -d "\$nl\\" |
awk '{print substr(\$0, 1, 100)}' |
sed 's/\.//; s/./&, /g' |
fmt -88 |
sed 's/, /,/g'
echo "OEIS:"
curl -s "http://oeis.org/search?q=id:\$1&fmt=text" | grep '%[STU]' |
awk '{print \$3}' |
tr -d ",\$nl" |
awk '{print substr(\$0, 1, 100)}' |
sed 's/\.//; s/./&, /g' |
fmt -88 |
sed 's/, /,/g'
echo
}

run A004542 2 5
run A004582 8 7
run A004583 8 8
run A004584 8 9
run A004588 10 5
\$

```