#!/bin/bash

x=(1 2)
len=${#x[@]}

# 最後の2つ
idx=${x[$((len - 1))]}
Idy=${x[$((len - 2))]}

sum=$(( x[$idx] - x[$Idy] ))
x+=( "$sum" )

echo "${x[@]}"

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: