Path: utzoo!utgpu!water!watmath!clyde!bellcore!faline!thumper!ulysses!andante!alice!ark From: ark@alice.UUCP Newsgroups: comp.lang.c Subject: Re: algorithm to convert N into base 3 wanted! Message-ID: <8130@alice.UUCP> Date: 24 Aug 88 02:07:49 GMT References: <650003@hpcilzb.HP.COM> Organization: AT&T Bell Laboratories, Liberty Corner NJ Lines: 15 In article <650003@hpcilzb.HP.COM>, tedj@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@europa.att.com