Skip to content

Instantly share code, notes, and snippets.

@4d47
Created April 12, 2017 12:32
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 4d47/22ac4ee70b178bfeb1e4e52862294e84 to your computer and use it in GitHub Desktop.
Save 4d47/22ac4ee70b178bfeb1e4e52862294e84 to your computer and use it in GitHub Desktop.
# 0.25 500$
# 2000,
use IO::Prompt;
# http://www.builtlean.com/2010/05/04/ideal-body-weight-formula-how-to-calculate-your-ideal-weight/
sub postfix:<%>(Numeric $x --> Numeric) {
$x / 100
}
my $body-weight = ask 'Weight:', :type(Num);
my $body-fat-precentage = (ask 'Fat percentage:', :type(Num))%;
my $desired-body-fat-percentage = (ask 'Target fat percentage:', 25, :type(Num))%;
my $lean-body-mass =
$body-weight - ($body-weight * $body-fat-precentage);
my $ideal-body-weight =
$lean-body-mass / (1 - $desired-body-fat-percentage);
say 'Target weight: ' ~ $ideal-body-weight;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment