Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {{ $cArgInt := carg "int" "int" }}
- {{ $args := parseArgs 3 "Prameters for Sum of Arithmetic Series a, d, n" $cArgInt $cArgInt $cArgInt }}
- {{ $a := $args.Get 0 }} {{ $d := $args.Get 1 }} {{ $n := $args.Get 2 }} {{ $sum := 0 }}
- {{/* To verify range loop's return we build the formula using math functions */}}
- Verification: {{ mult (div $n 2) (add (mult 2 $a) (mult $d (sub $n 1) ) ) -}}
- {{ range seq 0 $n }} {{ $sum = add $sum $a }} {{ $a = add $a $d }} {{ end }}
- Answer: {{ $sum }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement