#!/bin/bash # factr.sh: Factor a number MIN=2 # Will not work for number smaller than this. E_NOARGS=65 E_TOOSMALL=66 if [ -z $1 ] then echo "Usage: $0 number" exit $E_NOARGS fi if [ "$1" -lt "$MIN" ] then echo "Number to factor must be $MIN or greater." exit $E_TOOSMALL fi # Exercise: Add type checking (to reject non-integer arg). echo "Factors of $1:" # ------------------------------------------------------------------------------- echo "$1[p]s2[lip/dli%0=1dvsr]s12sid2%0=13sidvsr[dli%0=1lrli2+dsi!>.]ds.xd1<2"|dc # ------------------------------------------------------------------------------- # Above line of code written by Michel Charpentier <charpov@cs.unh.edu>. # Used in ABS Guide with permission (thanks!). exit 0