algorithm to convert N into base 3 wanted!
ark at alice.UUCP
ark at alice.UUCP
Wed Aug 24 12:07:49 AEST 1988
In article <650003 at hpcilzb.HP.COM>, tedj at hpcilzb.UUCP writes:
> Does anyone know of an algorithm to convert a positive integer N into
> its base 3 representation? (e.g., 14 in base 10 is 112 in base 3).
To convert a number to base N:
void convert(unsigned x, unsigned N)
{
if (x >= N)
convert(x/N, N);
printdigit(x%N);
}
--
--Andrew Koenig
ark at europa.att.com
More information about the Comp.lang.c
mailing list