Deceptive numbers: Difference between revisions
Content deleted Content added
→UNIX Shell: add |
→UNIX Shell: simplify |
||
Line 171:
/* wheel to skip multiples of 2, 3, and 5 */
w[0] =
w[1] =
w[2] =
w[3] =
w[4] =
w[5] =
w[6] =
w[7] =
for (n =
if (d(n += w[i]) == 1) {
n
c += 1
}
}</syntaxhighlight>
{{out}}
Line 1,231 ⟶ 1,230:
=={{header|UNIX Shell}}==
Works with [[POSIX]]-compatible shells.
<syntaxhighlight lang="sh">is () {
return "$((!($1)))"
}
set -- 1 "$
while is "$3
do
set -- "$(($1 * (($2 ^ 1) * ($3 & 1) ^ 1) % $4))" "$(($2 * $2 % $4))" "$(($3 >> 1))" "$4"
done
}
c=0 n=
▲set -- "$n"
while :
do
for w in 4 2 4 2 4 6 2 6
do
do
is 'p * p > n' && {
|