Skip to content

Instantly share code, notes, and snippets.

@paulojeronimo
Created July 18, 2022 19:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulojeronimo/3cc49d0d8875b8aa2625e2cdfa28c630 to your computer and use it in GitHub Desktop.
Save paulojeronimo/3cc49d0d8875b8aa2625e2cdfa28c630 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
cat <<'EOF'
If we divide 1 by 998001 we get the number ".000 001 002 003 ... 997 999 ...".
Look how curious: the 998 simply disappears!
Want proof? Read the code of this script!
Read more: https://www.linkedin.com/feed/update/urn:li:activity:6954872558508732416/
EOF
printNcharsFromS() {
while [ $i -lt $MAX ]
do
echo -n "${S:$i:$N} "
i=$(($i+$N))
done
}
scale=$((3*10*10*10))
bigNumber=$(echo "scale=$scale; 1/998001" | bc | tr -d '\n\\')
i=0 N=4 MAX=4 S=$bigNumber printNcharsFromS
i=4 N=3 MAX=$scale S=$bigNumber printNcharsFromS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment