#!/bin/bash
# COMP 198  Spring 2026
# bash6.sh
# Use an array to count occurances of random integers

for i in {1..10}           # set up an array; fill with 0
do
    let nums[$i]=0         # creates array on the fly
done

# do 1000 times
for i in {1..1000}
do
    let index=$RANDOM%10+1             # get a random number from 1 to 10
    let nums[$index]=${nums[$index]}+1 # note use of {} here rather than ()!
done

for i in {1..10}           # display the counts; should get ~100 in each
do
    echo ${nums[$i]}
done
