Skip to content

Instantly share code, notes, and snippets.

@AbhishekGhosh
Created January 25, 2015 17:52
Show Gist options
  • Save AbhishekGhosh/847323ec7d35c678fa26 to your computer and use it in GitHub Desktop.
Save AbhishekGhosh/847323ec7d35c678fa26 to your computer and use it in GitHub Desktop.
Pyramid Ball Count per Layer
#!/bin/bash
# If there are 4 layers, run 3 times and add 1
# GNU GPL 3.0
# Dr. Abhishek Ghosh 2015
echo "What is the number of Layer counted from the Top?:"
read input
echo "Then the $input th layer will have ::"
echo "\x1B[36m$(((input * 2)+((input - 2)*2)+((input - 2)*2)))\x1B[0m balls, if it is solid,"
echo "and \x1B[36m$(((input*2)+((input - 2)*2)))\x1B[0m balls, if it is hollow!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment