#!/bin/bash
# Prompt the user to enter the value of n
read -p "Enter the value of n: " n

sum=0
counter=1

# Calculate the sum using a while loop
while [ $counter -le $n ]
do
    read -p "Enter number $counter: " number
    sum=$((sum + number))
    counter=$((counter + 1))
done

# Output the sum
echo "The sum of the $n numbers is $sum."

Embed on website

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