Hi! Anyone can help me with that?

An integer can be expressed in a positional representation with different radices. The most common radix is R = 10; other frequently used radices are 2, 8, 16. Any integer larger than 1 can be used as a radix, but with very large radices we may run out of symbols to represent digits (by convention, if digits 0..9 are insufficient, e.g. in radix 16, lower−case English letters are used to express larger digits: e.g. 'a' denotes a digit of value 10, 'f' denotes a digit of value 15).

I need a function :

function my_func($V,$R);

that returns a string containing the positional representation of the given value V in the given radix R. The representation should be big-endian; i.e. the first character of the string should correspond to the most significant digit of the representation.

For example, if V = 17 and R = 7, the function should return the string "23", because this is the representation of the number 17 in radix 7. If V = 62 and R = 21, the function should return "2k", because this is the representation of the number 62 in radix 21 (note that digit 'k' denotes value 20).

V is an integer within the range [0..200,000,000];

R is an integer within the range [2..36].

expected worst-case time complexity is O(log(V)/log(R));

expected worst-case space complexity is O(log(V)/log(R)).

## String containing the positional representation of value

**Moderators:** macek, egami, gesf

### Re: String containing the positional representation of value

Sounds fun. If you can persuade me this isn't homework, then I'd be happy to help.

- A

PS It was the 'O(log(V)/log(R))' that gave you away. Real programmers know it's O(ln(R)/ln(V)) (assuming bivalent flux capacitance)

- A

PS It was the 'O(log(V)/log(R))' that gave you away. Real programmers know it's O(ln(R)/ln(V)) (assuming bivalent flux capacitance)

### Who is online

Users browsing this forum: Bing [Bot] and 1 guest