Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,19 @@
# First 30 positive integers which are squares but not cubes
# also, the first 3 positive integers which are both squares and cubes
######
# main #
######
integer n sq cr cnt=0
for (( n=1; cnt<30; n++ )); do
(( sq = n * n ))
(( cr = cbrt(sq) ))
if (( (cr * cr * cr) != sq )); then
(( cnt++ ))
print ${sq}
else
print "${sq} is square and cube"
fi
done

View file

@ -0,0 +1,28 @@
#!/usr/bin/env bash
main() {
local non_cubes=()
local cubes=()
local cr=1 cube=1 i square
for (( i=1; $#non_cubes < 30; ++i )); do
(( square = i * i ))
while (( square > cube )); do
(( cr+=1, cube=cr*cr*cr ))
done
if (( square == cube )); then
cubes+=($square)
else
non_cubes+=($square)
fi
done
printf 'Squares but not cubes:\n'
printf $non_cubes[1]
printf ', %d' "${(@)non_cubes[2,-1]}"
printf '\n\nBoth squares and cubes:\n'
printf $cubes[1]
printf ', %d' "${(@)cubes[2,-1]}"
printf '\n'
}
main "$@"