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

  • Home
  • SEARCH
  • 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 84031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:52:01+00:00 2026-05-10T21:52:01+00:00

Suppose we have n elements, a 1 , a 2 , …, a n

  • 0

Suppose we have n elements, a1, a2, …, an, arranged in a circle. That is, a2 is between a1 and a3, a3 is between a2 and a4, an is between an-1 and a1, and so forth.

Each element can take the value of either 1 or 0. Two arrangements are different if there are corresponding ai‘s whose values differ. For instance, when n=3, (1, 0, 0) and (0, 1, 0) are different arrangements, even though they may be isomorphic under rotation or reflection.

Because there are n elements, each of which can take two values, the total number of arrangements is 2n.

Here is the question:

How many arrangements are possible, such that no two adjacent elements both have the value 1? If it helps, only consider cases where n>3.

I ask here for several reasons:

  1. This arose while I was solving a programming problem
  2. It sounds like the problem may benefit from Boolean logic/bit arithmetic
  3. Maybe there is no closed solution.
  • 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. 2026-05-10T21:52:01+00:00Added an answer on May 10, 2026 at 9:52 pm

    Let’s first ask the question ‘how many 0-1 sequences of length n are there with no two consecutive 1s?’ Let the answer be A(n). We have A(0)=1 (the empty sequence), A(1) = 2 (‘0’ and ‘1’), and A(2)=3 (’00’, ’01’ and ’10’ but not ’11’).

    To make it easier to write a recurrence, we’ll compute A(n) as the sum of two numbers:
    B(n), the number of such sequences that end with a 0, and
    C(n), the number of such sequences that end with a 1.

    Then B(n) = A(n-1) (take any such sequence of length n-1, and append a 0)
    and C(n) = B(n-1) (because if you have a 1 at position n, you must have a 0 at n-1.)
    This gives A(n) = B(n) + C(n) = A(n-1) + B(n-1) = A(n-1) + A(n-2). By now it should be familiar 🙂

    A(n) is simply the Fibonacci number Fn+2 where the Fibonacci sequence is defined by
    F0=0, F1=1, and Fn+2= Fn+1+Fn for n ≥ 0.

    Now for your question. We’ll count the number of arrangements with a1=0 and a1=1 separately. For the former, a2 … an can be any sequence at all (with no consecutive 1s), so the number is A(n-1)=Fn+1. For the latter, we must have a2=0, and then a3…an is any sequence with no consecutive 1s that ends with a 0, i.e. B(n-2)=A(n-3)=Fn-1.

    So the answer is Fn+1 + Fn-1.

    Actually, we can go even further than that answer. Note that if you call the answer as
    G(n)=F
    n+1+Fn-1, then
    G(n+1)=Fn+2+Fn, and
    G(n+2)=Fn+3+Fn+1, so even G(n) satisfies the same recurrence as the Fibonacci sequence! [Actually, any linear combination of Fibonacci-like sequences will satisfy the same recurrence, so it’s not all that surprising.] So another way to compute the answers would be using:
    G(2)=3
    G(3)=4
    G(n)=G(n-1)+G(n-2) for n≥4.

    And now you can also use the closed form Fn=(αn-βn)/(α-β) (where α and β are (1±√5)/2, the roots of x2-x-1=0), to get
    G(n) = ((1+√5)/2)n + ((1-√5)/2)n.
    [You can ignore the second term because it’s very close to 0 for large n, in fact G(n) is the closest integer to ((1+√5)/2)n for all n≥2.]

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

Sidebar

Ask A Question

Stats

  • Questions 78k
  • Answers 78k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer I suppose you can use the SQLMetal command tool EDIT… May 11, 2026 at 3:57 pm
  • added an answer I would make the contents of each tab be called… May 11, 2026 at 3:57 pm
  • added an answer As others have said, you need to escape values that… May 11, 2026 at 3:57 pm

Related Questions

Suppose we have n elements, a 1 , a 2 , ..., a n
Suppose we have a vector/array in C++ and we wish to count which of
Of course most languages have library functions for this, but suppose I want to
This question is coded in pseudo-PHP, but I really don't mind what language I
I have embedded a Python interpreter in a C program. Suppose the C program

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.