Table of Contents

Purpose

Procedure and Necessary Knowledge

Miscellaneous

The Script

#!/bin/bash

a=0
echo -n "please enter a base: "
read base
echo -n "please enter a number: "
read number
until [ $number -eq 0 ]; do
	n=0
	until [ `echo "$number-$base^$n" | bc` -lt 0 ]; do
		let n=$n+1
	done
	let n=$n-1
	let number=$number-`echo "$base^$n" | bc`
	places=""
	for((i=0;i<$n;i++)); do
		places="${places}0"
	done
	places="1${places}"
		a=`echo "$a+$places" | bc`
done
echo "The value in base $base is: $a"
exit 0

Attributes