Suppose we're given a set $S=\{1,2,3,4,5\}$. From elements in $S$, we form an array/sequence of length $n$, such that difference between neighboring elements is strictly $1$. For example, one valid sequence of length $n = 5$ is $32345$. What is the generating function for the number of such sequences? My approach is to let $f(n)$ be a number of such sequences starting with 1 or 5 (only one neighboring number). Then, $f(n) = 2 * n-1$. Similiarly, let $g(n)$ be a number of sequences staring with $2,3,4$. Unfortunately, I can't find a proper formula for $g(n)$, although I'm quite convinced it's in the form of $a\times g(n-1) + b\times f(n-1)$.
How do I find a recursion formula to solve the following question:  In how many sequences of length $n$, with elements from $\{{0,1,2,3,4}\}$, the difference between every 2 adjacent elements is $1$ or $-1$?  I've been trying to solve the problem for the last 5 hours maybe, I'm sure that I'm missing something..   This is a problem in combinatorics, and the solution must be by finding a recursion formula for the problem.   best solution I've come so far is that if we say that $a_n$ is the solution to the question, so let's count how many sequences of size $n-1$ there are that meet the requirement, and we complete the first element to make it a sequence of $n$ elements. so for $n-1$ there $a_{n-1}$ sequences, and for each sequence we have $2$ options to choose the first element (one option is to take a plus $1$ number from the number that start the $n-1$ sequence, and the other option to to take a minus $1$ number from the number that start the $n-1$ sequence), only problem as you figured out is that if the $n-1$ sequnce starts with $0$ or $4$ there is only $1$ option left for the first element in the sequnce.. so $a_n=2a_{n-1}$ won't work.  I think that the solution may involve using $2$ or maybe $3$ recursion formulas.  Hope I was clear enough.
What are the most commonly used and basic Apache htaccess redirects? This question is here so we can offer users who are looking for information on how to make one or more common or basic redirects in Apache using the htaccess file. All future questions pertaining to finding information that is that is covered by the question should be closed as a duplication of this question. .  Whats the point in this question? The idea while not perfect is catch the most commonly asked questions regarding redirects using the  htaccess on the Apache platform either on  some type of lamp or a live server. The type of answers should be generally those that you could imagine are used by 100,000’s of sites world-wide and are constantly asked here at Pro Webmasters repeatedly over and over in various forms.  A few examples of the type of answers we are looking for:   How can I redirect non-www to www? How can I redirect a sub domain to the main domain? How can I redirect a sub folder from domain to a root or a subdomain?  How can I redirect an old URL to a new URL?   A few examples of the types of answers that we are not looking for:   Answers that do not involve a redirect. Any answers relating to NGinx, IIS or any other non-Apache platform. Answers that involve custom and complex string or query removals.   Resources for Advanced to Complex Mod_Rewrite Rules:      Please note: that this question is still in construction and may need some refining either by myself or a real moderator of Pro Webmasters, if you have any concerns or questions . Are PPAs safe to add to my system and what are some "red flags" to watch out for? Repeating (or not) "to" in a sentence involving infinitives set in parallel I googled it but I couldn't find the answer... maybe I didn't seek it in the proper way. My question is if &quot;to&quot; must be repeated in sentences such as the following ones:   In the past, women used to do the housework and to take care of children.  The aim of this meeting is to control their progress and to discuss the new working plan.    If I had to bet, I would omit the second to... But I am not sure about it. Is there really no way to power a DSLR by USB? Validate a username and password against Active Directory? How can I validate a username and password against Active Directory? I simply want to check if a username and password are correct. How to activate GRASS GIS 7 plugin in QGIS 2.8? Problem installing .deb in Software Install Ubuntu 20.04 Today I've suddenly received spam calendar invitation for $19.99 Ray Ban sunglasses (never subscribed, checked, searched or visited any related site, so clearly spam) and it has other visible email accounts within the invitation. I'm wondering if I should be worried whether my accounts been compromised or a simple email from anywhere just plops this in my calendar without review. Questions to be answered:  What should I check/setup in order to make sure my iCloud account is safe? How can I delete this invitation without sending a notification to the sender, so as to prevent them from knowing my email address is live? How can I prevent these notifications in the future?  Here's an image: Can I move the Unity launcher? How do I connect to my Bluetooth headset? I have an ACER C7 Chromebook with Ubuntu 12.04 installed.  Also I have two apps installed Bluetooth Manager and Bluetooth.    I am trying to connect an  to Ubuntu. I have tried to set up the new device and pair, but the headset is never recognized.  I checked hard and soft setting for Bluetooth and they are on.  I am new to Ubuntu 12.04 and Linux and need specific instructions. Performing multiple layer intersection in QGIS? Don't certain processes decrease entropy? Are there irreducible polynomials that are partially solvable by radicals? In general, polynomials of degree 5 or higher, with rational coefficients, are not solvable by radicals. There are some exceptions and trivial cases, for example $x^5-5x+12$ and $x^{100}+x^{25}+3$, respectively.  All irreducible polynomials with rational coefficients, that I am aware of, have either none or all roots that can be expressed by radicals.  Do partially-solvable irreducible polynomials exist? If they do, are there any examples known?  I mean, for example, an irreducible polynomial of $n$th degree that can be split over $Q(\sqrt{2})$ into two polynomials of 3rd and $(n-3)$th degrees, where the polynomial of $(n-3)$th is not solvable by radicals.    At  Alexander Gruber wrote:     Polynomials which are not solvable by radicals have (at least one) root that cannot be written by any combination of the operations of addition, multiplication, and the taking of nth roots.   I am not sure if he meant only reducible polynomials, and/or with non-rational coefficients, as polynomials that have "at least one" root that cannot be expressed by radicals. Which kind of pointer do I use when? How do I convert between big-endian and little-endian values in C++? How do I convert between big-endian and little-endian values in C++? For clarity, I have to translate binary data (double-precision floating point values and 32-bit and 64-bit integers) from one CPU architecture to another.  This doesn't involve networking, so ntoh() and similar functions won't work here.  Note: The answer I accepted applies directly to compilers I'm targeting (which is why I chose it).  However, there are other very good, more portable answers here. Best Pattern For Adding Commentary in align Environment? I've been using the align environment to line up equations in proofs/explanations/etc and I like to place parenthetical commentary for each step, similar to the code below:  \documentclass{article} \usepackage{amsmath} \begin{document}  \begin{align*}   f(ax + by) &amp; = f(ax) + f(by) &amp; (By Property 1) \\              &amp; = af(x) + bf(y) &amp; (By Property 2) \\ \end{align*}  \end{document}   The problem I have with this is that the commentary completely distorts the overall alignment of the equation area; far too much space is allocated to the column containing the commentary.  I would like, insofar as it is possible, for the equations themselves to be aligned in the center of the page and for the commentary to simply appear on the right without affecting the overall justification of the equations. What's the best way to achieve this? I've installed Ubuntu 13.04 two times on my PC. Each on a different partition. I would like to delete the one which I'm not using. How would I do that? The trigonometric ratios of an angle greater than $90^\circ$ are equal to the supplementary angle's ratios.  I'm just clarifying this, but the ratios don't actually exist for angles greater than $90^\circ$ right? (since by definition these ratios are of a right angle triangle). Is it just mathematical custom to assume the ratios of an angle greater than $90^\circ$ to be equivalent to its supplementary angle's ratios? For convenience? How to detect when a variable changes value How can I easily detect when a variable changes value? I would like the execution of the program to break on the debugger whenever a specified variable changes value. Right now I'm using Eclipse's debugger. MySQL string replace