Fractional Bases.

Level 2

The problem below is an extension of a problem I did on brillant.

Let 37 = ( a n a n 1 . . . a 0 ) 4 3 = ( b m b m 1 . . . b 0 ) 3 2 37 = (a_{n}a_{n - 1} ... a_{0})_{\frac{4}{3}} = (b_{m}b_{m - 1} ... b_{0})_{\frac{3}{2}} where ( 0 a j 3 ) (0 \leq a_{j} \leq 3) for ( 0 j n ) (0 \leq j \leq n) and ( 0 b j 2 ) (0 \leq b_{j} \leq 2) for ( 0 j m ) (0 \leq j \leq m) .

Find j = 0 n a j + j = 0 m b j \displaystyle \sum_{j = 0}^{n} a_{j} + \sum_{j = 0}^{m} b_{j} .

Note: Find a general algorithm to write integer expansions in fractional bases whose fractions are improper fractions.

Let A = 10 , B = 11 , C = 12 , D = 13 , E = 14 A = 10, B = 11, C =12, D = 13, E = 14 and F = 15 F = 15 .

Bonus: Write a program using the algorithm above to represent 123456789 123456789 in base 16 11 \dfrac{16}{11} .

Refer to brillant problem for further information:


The answer is 18.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

2 solutions

Let the initial decimal integer be k 0 k_0 and the improper fractional base be p q \dfrac pq , where p p and q q are positive coprime integers with p > q p>q . Then the j j th digit a j a_j is given by:

a j = k j m o d p where k j = q k j 1 p for j 1 a_j = k_j \bmod p \quad \small \text{where } k_j = q \left \lfloor \frac {k_{j-1}}p \right \rfloor \text{ for }j \ge 1

Let us use the formulas above to solve for k 0 = 37 k_0 = 37 , p = 4 p=4 , and q = 3 q=3 .

\(\begin{array} {} j= 0 & k_0 =37 & \implies a_0 = 37 \bmod 4 = 1 \\ j = 1 & k_1 = 3 \left \lfloor \dfrac {37}4 \right \rfloor = 27 & \implies a_1 = 27 \bmod 4 = 3 \\ j = 2 & k_2 = 3 \left \lfloor \dfrac {27}4 \right \rfloor = 18 & \implies a_2 = 18 \bmod 4 = 2 \\ j = 3 & k_3 = 3 \left \lfloor \dfrac {18}4 \right \rfloor = 12 & \implies a_3 = 12 \bmod 4 = 0 \\ j = 4 & k_4 = 3 \left \lfloor \dfrac {12}4 \right \rfloor = 9 & \implies a_4 = 9 \bmod 4 = 1 \\ j = 5 & k_5 = 3 \left \lfloor \dfrac 94 \right \rfloor = 6 & \implies a_5 = 6 \bmod 4 = 2 \\ j = 6 & k_6 = 3 \left \lfloor \dfrac 64 \right \rfloor = 3 & \implies a_6 = 3 \bmod 4 = 3 \\ j = 5 & k_7 = 3 \left \lfloor \dfrac 34 \right \rfloor = 0 & \implies a_7 = 0 \bmod 4 = 0 \end{array} \)

3 7 10 = 132012 3 4 3 \implies 37_{10} = 1320123_\frac 43 , Similarly, 3 7 10 = 101101 2 3 2 37_{10} = 1011012_\frac 32 . Therefore, j = 0 6 a j + j = 0 6 b j = 12 + 6 = 18 \displaystyle \sum_{j=0}^6 a_j + \sum_{j=0}^6 b_j = 12+6 = \boxed{18} .

The above formula or algorithm can be readily implemented with a Microsoft Excel spreadsheet, using functions =INT( _ ) for \lfloor \cdot \rfloor , the floor function and =MOD( _ , _ ) for m o d \cdot \bmod \cdot , the modulo operation . My spreadsheet is as follows. And 12345678 9 10 = B6C23A75ACC672C6A642CC9F11D9061CFC3C6EA5B5 16 11 123456789_{10} = \boxed{\text{B6C23A75ACC672C6A642CC9F11D9061CFC3C6EA5B5 }}_{\frac {16}{11}} .

Rocco Dalto
Feb 6, 2019

The simple algorithm below generates the conversion:

To calculate: [ M ] a b [M]_{\frac{a}{b}} , where ( a > b ) (a > b) .

Let S 1 = M S_{1} = M

Repeat

r n = S n m o d a r_{n} = S_{n} \mod a

q n = S n d i v a q_{n} = S_{n} \:\ div \:\ a

S n + 1 = b q n S_{n + 1} = b * q_{n}

Go until S n + 1 < a S_{n + 1} < a .

Using the algorithm above:

For ( 37 ) 4 3 (37)_{\frac{4}{3}} :

37 27 1 18 3 1 12 2 3 1 9 0 2 3 1 6 1 0 2 3 1 3 2 1 0 2 3 1 \boxed{37} \rightarrow \boxed{27} \boxed{1} \rightarrow \boxed{18} \boxed{3} \boxed{1} \rightarrow \boxed{12} \boxed{2} \boxed{3} \boxed{1} \rightarrow \boxed{9} \boxed{0} \boxed{2} \boxed{3} \boxed{1} \rightarrow \boxed{6} \boxed{1} \ \boxed{0} \boxed{2} \boxed{3} \boxed{1} \rightarrow \boxed{3} \boxed{2} \boxed{1} \ \boxed{0} \boxed{2} \boxed{3} \boxed{1}

For ( 37 ) 3 2 (37)_{\frac{3}{2}} :

37 24 1 16 0 1 10 1 0 1 6 1 1 0 1 4 0 1 1 0 1 2 1 0 1 1 0 1 \boxed{37} \rightarrow \boxed{24} \boxed{1} \rightarrow \boxed{16} \boxed{0} \boxed{1} \rightarrow \boxed{10} \boxed{1} \boxed{0} \boxed{1}\rightarrow \boxed{6} \boxed{1} \boxed{1} \boxed{0} \boxed{1} \rightarrow \boxed{4} \boxed{0} \boxed{1} \boxed{1} \boxed{0} \boxed{1} \rightarrow \boxed{2} \boxed{1} \boxed{0} \boxed{1} \boxed{1} \boxed{0} \boxed{1}

j = 0 6 a j + j = 0 6 b j = 18 \implies \sum_{j = 0}^{6} a_{j} + \sum_{j = 0}^{6} b_{j} = \boxed{18} .

Below is a program I wrote in Free Pascal::

program fractionalbase;

var myfile:text;

procedure change(var k:string);

begin IF K = '10' THEN K:= 'A';

IF K = '11' THEN K:= 'B';

IF K = '12' THEN K:= 'C';

IF K = '13' THEN K:= 'D';

IF K = '14' THEN K:= 'E';

IF K = '15' THEN K:= 'F';

end;

function fractbase(n,a,b:longint):string;

type myarray = array[1 .. 100] of longint;

var q,s,count,m:longint;

r:myarray;

strvar,strsum:string;

begin

s:= n;

count:= 1;

repeat

r[count]:= s mod a;

q:= s div a;

s:= b * q;

count:= count + 1;

until(s < a);

r[count]:= s mod a;

strsum:= '';

for m:= 1 to count do

begin

str(r[m],strvar);

if r[m] > 9 then

change(strvar);

strsum:= strvar + strsum;

end;

fractbase:= strsum;

end;

begin

assign(myfile,'fract.txt');

rewrite(myfile);

writeln(myfile,fractbase(123456789,16,11));

close(myfile);

readln;

end.

Running the above program we obtain:

( 123456789 ) 10 = ( B 6 C 23 A 75 A C C 672 C 6 A 642 C C 9 F 11 D 9061 C F C 3 C 6 E A 5 B 5 ) 16 11 (123456789)_{10} = \boxed{(B6C23A75ACC672C6A642CC9F11D9061CFC3C6EA5B5)_{\bf\frac{16}{11}}}

Below is a program I wrote in Python:

The module below contains the majority of the program: I wrote the module so I could use the function when needed.

import math;

def power(base,exponent):

product = 1;

n=1;

while n <= exponent:

product = product * base;

n = n + 1;

power = product

return power;

def change(k):

if k == 10:

  k = 'A'

if k == 11:

  k = 'B'

if k == 12:

  k = 'C'

if k == 13:

  k = 'D'

if k == 14:

  k = 'E'

if k == 15:

  k = 'F'

if k == 16:

  k = 'G'

change = k

return change;

import array

array.array('i')

r = array.array('i',(0 for i in range(0,1000)))

def fractbase(n,a,b):

s = n;

count = 1;

while s >= a:

r[count] = s % a;

q = math.floor(s/a);

s = b * q;

count = count + 1;

r[count] = s % a;

strsum = '';

for m in range(-count,0):

if r[-m] > 9:

      strsum = strsum + change(r[-m])

else:

      strsum = strsum + str(r[-m]);

fractbase = strsum;

return fractbase;

Calling the function::

print(mathunit.fractbase(123456789,16,11));

Running the above program we obtain:

( 123456789 ) 10 = ( B 6 C 23 A 75 A C C 672 C 6 A 642 C C 9 F 11 D 9061 C F C 3 C 6 E A 5 B 5 ) 16 11 (123456789)_{10} = \boxed{(B6C23A75ACC672C6A642CC9F11D9061CFC3C6EA5B5)_{\bf\frac{16}{11}}}

@Rocco Dalto , a nice problem. The bonus part, it should be converting 12345678 9 10 123456789_{10} to base 16 11 \frac {16}{11} . and not 12345678 9 16 11 123456789_{\frac {16}{11}} .

Chew-Seong Cheong - 2 years, 4 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...