fork download
  1. #!/usr/bin/env bash
  2.  
  3. read w h d s
  4. r=$(bc<<<"scale=5;($d^4 / $h^4 - 1) * $h * $w * 3 / 13 / (1 + $s)")
  5. r=${r#-}
  6. q=$(bc<<<"scale=5;sqrt($r)")
  7. t="$(for i in $(seq 1 ${q%%.*}); do
  8. m=$(bc<<<"scale=5;$r/$i")
  9. echo "${m##*.}|$i: $m"
  10. done | sort -n | cut -d\| -f2-)"
  11. echo -e "\nsqrt = $q\n"
  12. head -15 <<<"$t"
  13. echo ""
  14. tail -15 <<<"$t"
  15.  
Success #stdin #stdout 0.36s 5280KB
stdin
70 176 467 3
stdout
sqrt = 185.80067

111: 311.00802
37: 933.02407
177: 195.03893
40: 863.04727
117: 295.05889
66: 523.05895
170: 203.06994
145: 238.08200
20: 1726.09454
162: 213.09809
119: 290.09992
65: 531.10601
142: 243.11190
59: 585.11679
152: 227.11770

36: 958.94141
19: 1816.94162
178: 193.94320
2: 17260.94547
42: 821.94978
23: 1500.95178
166: 207.96319
122: 282.96631
63: 547.96652
84: 410.97489
126: 273.98326
137: 251.98460
79: 436.98596
41: 841.99734
82: 420.99867