jeudi 9 septembre 2021

Decomposition of power 3 using the power of three only once

So I am trying to write a java program that produces the decomposition of an integer using powers of three which are: 1, 3, 9, 27, and 81. Can only use the power of three once in each calculation.

Examples: 1 = 1

2 = 3 – 1

3 = 3

4 = 3 + 1

7 = 9 – 3 + 1

14 = 27 – 9 – 3 – 1

121 = 81 + 27 + 9 + 3 + 1

Observation: The intervals [-121,-41], [-40,-14], [-13,-5], [-4,-2], [-1,-1], [1,1], [2,4], [5,13], [14,40], and [41,121] play a particular role.

Aucun commentaire:

Enregistrer un commentaire