# Are there positive integers n,p such that 3^n = 2^p - 1?.  Plus related question.

**URL:** <https://boards.straightdope.com/t/are-there-positive-integers-n-p-such-that-3-n-2-p-1-plus-related-question/709056>\
**Category:** Factual Questions\
**Created:** [January 5, 2015, 7:41pm UTC](https://boards.straightdope.com/t/are-there-positive-integers-n-p-such-that-3-n-2-p-1-plus-related-question/709056 "2015-01-05T19:41:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![elfoldo](https://avatars.discourse-cdn.com/v4/letter/e/e47c2d/32.png) [@elfoldo](https://boards.straightdope.com/u/elfoldo)\
**Post date:** [January 5, 2015, 7:41pm UTC](https://boards.straightdope.com/t/are-there-positive-integers-n-p-such-that-3-n-2-p-1-plus-related-question/709056/1 "2015-01-05T19:41:46Z")

</div>

I was wondering if there’s any positive integer power of 3 which is 1 less than a positive integer power of 2. The powers don’t have to be the same.

3[sup]n[/sup] = 2[sup]p[/sup] -1 where n,p are positive integers.

I wrote a program looking for any suitable n/p values, but I couldn’t find any. My program was limited to going up to 3[sup]647[/sup]

I noticed that it’s easy to find where 3[sup]n[/sup] = 2[sup]p[/sup] +1. An quick answer can be found with 3[sup]2[/sup] = 2[sup]3[/sup] + 1

My related question has to do with representing the 3[sup]n[/sup] value as a series of 2 to the power of some other numbers without coefficients. For example, I could write 3[sup]4[/sup]=81 as:

3[sup]4[/sup] = 81 = 2[sup]6[/sup] + 2[sup]4[/sup] + 2[sup]0[/sup] = 64 + 16 + 1

As a shorthand, I would say that 3[sup]4[/sup] could be represented by the sum of 2 to the powers of [6 4 0] and 3 terms are needed.

I also had my program print out the 2-to-the-power reduction for the various 3[sup]n[/sup]. One thing that surprised me was that there was limited number of terms required regardless of the value of n. To represent the numbers for 3[sup]n[/sup], where n are the integers from 20 to 647, the maximum number of terms needed was about 38. That surprises me because to represent a number like 2[sup]p[/sup] - 1 requires p terms. For example:

2[sup]5[/sup] - 1 = 31 = 2[sup]4[/sup] + 2[sup]3[/sup] + 2[sup]2[/sup] + 2[sup]1[/sup] + 2[sup]0[/sup] = 16 + 8 + 4 + 2 + 1

However, 3[sup]626[/sup] only requires 20 terms:

3[sup]626[/sup] = 2[sup]992[/sup] + 2[sup]989[/sup] + 2[sup]985[/sup] + 2[sup]984[/sup] + 2[sup]982[/sup] + 2[sup]980[/sup] + 2[sup]978[/sup] + 2[sup]976[/sup] + 2[sup]974[/sup] + 2[sup]968[/sup] + 2[sup]966[/sup] + 2[sup]959[/sup] + 2[sup]957[/sup] + 2[sup]956[/sup] + 2[sup]953[/sup] + 2[sup]949[/sup] + 2[sup]946[/sup] + 2[sup]945[/sup] + 2[sup]942[/sup] + 2[sup]0[/sup]

So my related question is this: Is there a maximum number of 2-to-the-power-of terms which can represent any 3[sup]p[/sup] number where, p is an integer from 1-\>infinity?

---

<div class="post-metadata">

**Author:** ![septimus](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/septimus/32/410_2.png) [@septimus](https://boards.straightdope.com/u/septimus)\
**Post date:** [January 5, 2015, 8:15pm UTC](https://boards.straightdope.com/t/are-there-positive-integers-n-p-such-that-3-n-2-p-1-plus-related-question/709056/2 "2015-01-05T20:15:53Z")

</div>

> [@elfoldo](#):
>
> I was wondering if there’s any positive integer power of 3 which is 1 less than a positive integer power of 2.
> 
> I noticed that it’s easy to find where 3[sup]n[/sup] = 2[sup]p[/sup] +1. An quick answer can be found with 3[sup]2[/sup] = 2[sup]3[/sup] + 1

Yes, 3[sup]1[/sup] = 2[sup]2[/sup] -1  
You note 3[sup]2[/sup] = 2[sup]3[/sup] +1. Also 3[sup]1[/sup] = 2[sup]1[/sup] +1 😃  
_ **But these simple cases exhaust the adjacent powers of two or three.** _ Proof of this fact is among the [mathematical gems of Rabbi Levi ben Gershon (1288-1344)](http://web.stonehill.edu/compsci/shai_papers/gems.pdf).

---

<div class="post-metadata">

**Author:** ![septimus](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/septimus/32/410_2.png) [@septimus](https://boards.straightdope.com/u/septimus)\
**Post date:** [January 5, 2015, 8:37pm UTC](https://boards.straightdope.com/t/are-there-positive-integers-n-p-such-that-3-n-2-p-1-plus-related-question/709056/3 "2015-01-05T20:37:44Z")

</div>

> [@elfoldo](#):
>
> However, 3[sup]626[/sup] only requires 20 terms:
> 
> 3[sup]626[/sup] = 2[sup]992[/sup] + 2[sup]989[/sup] + 2[sup]985[/sup] + 2[sup]984[/sup] + 2[sup]982[/sup] + 2[sup]980[/sup] + 2[sup]978[/sup] + 2[sup]976[/sup] + 2[sup]974[/sup] + 2[sup]968[/sup] + 2[sup]966[/sup] + 2[sup]959[/sup] + 2[sup]957[/sup] + 2[sup]956[/sup] + 2[sup]953[/sup] + 2[sup]949[/sup] + 2[sup]946[/sup] + 2[sup]945[/sup] + 2[sup]942[/sup] + 2[sup]0[/sup]

You may need a new calculater! (i’ll guess yours doesn’t handle large numbers.) The LHS and RHS are very close, but unequal.  
The number of powers of 2 that sum to any number is simply the number of 1’s in that number’s binary representation which, for 3[sup]626[/sup], is about 473 I think.

---

<div class="post-metadata">

**Author:** ![Hector\_St\_Clare](https://avatars.discourse-cdn.com/v4/letter/h/b5ac83/32.png) [@Hector\_St\_Clare](https://boards.straightdope.com/u/Hector_St_Clare)\
**Post date:** [January 5, 2015, 8:41pm UTC](https://boards.straightdope.com/t/are-there-positive-integers-n-p-such-that-3-n-2-p-1-plus-related-question/709056/4 "2015-01-05T20:41:40Z")

</div>

> [@septimus](#):
>
> Yes, 3[sup]1[/sup] = 2[sup]2[/sup] -1  
> You note 3[sup]2[/sup] = 2[sup]3[/sup] +1. Also 3[sup]1[/sup] = 2[sup]1[/sup] +1 😃  
> _ **But these simple cases exhaust the adjacent powers of two or three.** _ Proof of this fact is among the [mathematical gems of Rabbi Levi ben Gershon (1288-1344)](http://web.stonehill.edu/compsci/shai_papers/gems.pdf).

Wow, that’s amazing, especially given when the Rabbi lived.

Levi ben Gershon (aka Gersonides) plays a large role as a fictional character in one of my favourite popular novels, Iain Pears’ _The Dream of Scipio_. (In that novel, much like his other _Instance of the Fingerpost_, he includes a great many real-life historical figures as characters). I didn’t know he was a mathematician, though the book portrays him as a kind of all-around polymathic scolar.

---

<div class="post-metadata">

**Author:** ![Senegoid](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/senegoid/32/6606_2.png) [@Senegoid](https://boards.straightdope.com/u/Senegoid)\
**Post date:** [January 6, 2015, 8:36pm UTC](https://boards.straightdope.com/t/are-there-positive-integers-n-p-such-that-3-n-2-p-1-plus-related-question/709056/5 "2015-01-06T20:36:24Z")

</div>

> [@elfoldo](#):
>
> My related question has to do with representing the 3[sup]n[/sup] value as a series of 2 to the power of some other numbers without coefficients. For example, I could write 3[sup]4[/sup]=81 as:
> 
> 3[sup]4[/sup] = 81 = 2[sup]6[/sup] + 2[sup]4[/sup] + 2[sup]0[/sup] = 64 + 16 + 1
> 
> As a shorthand, I would say that 3[sup]4[/sup] could be represented by the sum of 2 to the powers of [6 4 0] and 3 terms are needed.

Well, _any_ positive integer can be represented as the sum of various powers of 2 without coefficients. That is nothing more than the binary system, or numbers written in base-2.

And yes, the maximum number of terms you would ever need to represent a number up to 2[sup]n[/sup]-1, for some n, is log[sub]2/sub, or simply n. Thus, for example, to represent 2[sup]321[/sup]-1 requires all 321 terms.
