#!/usr/bin/env bash

read w h d s
r=$(bc<<<"scale=5;($d^4 / $h^4 - 1) * $h * $w * 3 / 13 / (1 + $s)")
r=${r#-}
q=$(bc<<<"scale=5;sqrt($r)")
t="$(for i in $(seq 1 ${q%%.*}); do
    m=$(bc<<<"scale=5;$r/$i")
    echo "${m##*.}|$i: $m"
done | sort -n | cut -d\| -f2-)"
echo -e "\nsqrt = $q\n"
head -15 <<<"$t"
echo ""
tail -15 <<<"$t"
