~scripts
40 itemsDownload ./*


..
dzen2
tiling
vosh
4cdl
4trips
alarm
ambient
battery-monitor
checkit
cleverbot.py
clock
color-gen
colors-hex
compton
dailywall
dmenu
importw
indexer
keep-on
mp3ogg
orage
pipes
pipes.x
rain
randwall
screen-dim
screencast
screencast2
scrot
scrotw
search
skull
slocker
starwars
streamit
sumnum
tty-colorize
usrmount
ytp
ytplay


scriptssumnum
8 months agoDownloadRawClose


#!/bin/bash
#
# Author:      Twily                                                                    2017
# Description: Sum of numbers between N1 and N2
# Usage:       sh ./sumnum 30 50
# Source:      https://www.easycalculation.com/faq/1454/sum_of_numbers_from_51_to_100_is.php
#

N1=$1
N2=$2

SUM=$(( ($N2*($N2+1)/2)-($N1*($N1+1)/2) ))
AVG=$(( $SUM/2 ))

echo "SUM: $SUM"
echo "AVG: $AVG"

exit

Top
twily at openmailbox dot org
©twily.info 2013 - 2017



744 056 visits
... ^ v