11.05.2012

if x even - (x+1)/2*e
if x odd - x/2*e+(e/2)
$ x=0;y=0;for i in {1..15};do x=$(($x+1));y=$(($y+$x));e=$y;echo day $i: $e;done
day 1: 1
day 2: 3
day 3: 6
day 4: 10
day 5: 15
day 6: 21
day 7: 28
day 8: 36
day 9: 45
day 10: 55
day 11: 66
day 12: 78
day 13: 91
day 14: 105
day 15: 120

$ x=0;y=0;for i in {1..347};do x=$(($x+1));y=$(($y+$x));e=$y;echo day $i: $e;done|grep 'day 347'
day 347: 60378
(347+1)/2*347=60378

$ x=0;y=0;for i in {1..347};do x=$(($x+1));y=$(($y+$x));e=$y;echo day $i: $e;done|grep 'day 346'
day 346: 60031
((346/2)*346)+(346/2)=60031

Комментариев нет: