Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8315131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:03:39+00:00 2026-06-08T21:03:39+00:00

I am looking for a reasonably fast algorithm to calculate terms of the OEIS

  • 0

I am looking for a reasonably fast algorithm to calculate terms of the OEIS sequence A002845. Let me restate its definition here.

Let ^ denote the exponentiation operator. Consider expressions of the form 2^2^…^2 having n 2’s with parentheses inserted in all possible ways (the number of possible parenthesizations is given by Catalan numbers). Some of these expressions will have the same value, for example (2^2)^2=2^(2^2). We are interested in the number of distinct values for a given n.

There is an obvious brute-force solution through a direct calculation of these expressions, but it is clear that the required time and space quickly exceed all reasonable limits even for relatively small n. I’m interested in a polynomial-time solution to this problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T21:03:42+00:00Added an answer on June 8, 2026 at 9:03 pm

    Just represent the numbers in iterated base 2: a Num has a (possibly empty) list of distinct children x1,...,xp of type Num, so that Num([x1,...,xp]) == 2^x1 + ... + 2^xp.

    This defines a unique way to write a nonnegative integer; remember to sort the exponents so that comparison makes sense. The equalities:

    • 2^x + 2^x == 2^(x+1) == Num([x+1])
    • 2^x + 2^y == Num([x,y]) when x != y
    • (2^2^x)^2^y == 2^2^(x+y) == Num([Num([x+y])])

    along with associativity/commutativity of addition allow you to add arbitrary numbers and compute x^y for numbers of the form 2^2^k; this class of numbers contains 2 (with k=0) and is closed under ^ so this guarantees that every number we need to manipulate is of this form.

    Furthermore, the equalities defined above never increase the number of nodes in the tree, so all the Num are of size O(n).

    So the time complexity is actually O(C * n^k) which is quasi-linear in C (C is the (n-1)-th Catalan number).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For use with a class I'll be teaching, I'm looking for a fast compiler
I'm looking to for a reasonably efficient way of determining if a floating point
I'm looking into creating custom controls for WPF and I've found some reasonably useful
I'm looking for a forward error-correcting code that is relatively easy/fast to encode on
Is there a reasonably fast way to extract the exponent and mantissa from a
I am looking for an open source Java project containing two reasonably complete test
I'm working on a website with reasonably heavy traffic and I'm looking into using
I'm looking for an algorithm to solve the following in a reasonable amount of
Id like to redesign some aspects of my database/website, and am looking for reasonably
I'm looking for an Xcode project file that will let me trivially build a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.