Skip to content

Commit 51a84ea

Browse files
Add CAGR calculation script within math folder (#965)
* Add CAGR calculation script within math folder. * Update calculate-CAGR.sh with descriptive naming Co-authored-by: Thiago Holanda <[email protected]> --------- Co-authored-by: Thiago Holanda <[email protected]>
1 parent 3bea3b8 commit 51a84ea

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

commands/math/calculate-CAGR.sh

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
# Required parameters:
4+
# @raycast.schemaVersion 1
5+
# @raycast.title Calculate CAGR Percentage
6+
# @raycast.mode compact
7+
# @raycast.packageName Math
8+
9+
# Optional parameters:
10+
# @raycast.argument1 { "type": "text", "placeholder": "From" }
11+
# @raycast.argument2 { "type": "text", "placeholder": "To" }
12+
# @raycast.argument3 { "type": "text", "placeholder": "Years" }
13+
14+
# Documentation:
15+
# @raycast.author Samuel Barton
16+
# @raycast.authorURL https://github.com/samueldbarton
17+
# @raycast.description Calculate the CAGR between "from" and "to" values over given "years," then copy the result.
18+
19+
CAGR=$(echo "scale=4; e( l($2 / $1) / $3 ) - 1" | bc -l)
20+
CAGR=$(echo "scale=2; $CAGR * 100" | bc -l)
21+
CAGR=$(printf "%.2f" "$CAGR")
22+
echo "$CAGR" | pbcopy
23+
echo "The CAGR from $1 to $2 over $3 years is $CAGR%. CAGR copied to clipboard."

0 commit comments

Comments
 (0)