How many sequnces can be made with 5 digits so that the difference between any two consecutive digits is $1$?












5












$begingroup$


Using the digits $0$, $1$, $2$, $3$, and $4$, how many ten digit sequences can be written so
that the difference between any two consecutive digits is $1$?



I was wondering if my solution is right.



Let $a(n)$ be the number of n digit sequences that end with $0$ or $4$ so
that the difference between any two consecutive digits is $1$.



$b(n)$ be the number of n digit sequences that end with $1$ or $3$ so
that the difference between any two consecutive digits is $1$.



$c(n)$ be the number of n digit sequences that end with $2$ so
that the difference between any two consecutive digits is $1$.



$x(n)$ be the number of n digit sequences so
that the difference between any two consecutive digits is $1$.



$x(n) = a(n) + b(n) + c(n)$



$a(n) = b(n-1)$



$b(n) = a(n-1) + 2c(n-1)$



$c(n) = b(n-1)$



By substituting $a(n-1)$ and $c(n-1)$ in the formula for $b(n)$ we get $b(n) = 3b(n-2)$



We know that $b(1) = 2, b(2) = 4$.



The characteristic equation for this recurssion is $x^2-3 = 0$ with have the roots $3^{1/2}$ and $-3^{1/2}$, so $b(n) = A{(3^{1/2})}^{n} + B{(-3^{1/2})}^{n}$ where $A = {(3^{1/2}+2)}/{3}$ and $B = {(2-3^{1/2})}/{3}$. I think this is an integer.



We get $x(n) = 2b(n-1) + 3b(n-2)$ and by substituting we get something.










share|cite|improve this question











$endgroup$












  • $begingroup$
    You get $b(n)=3b(n-2)$
    $endgroup$
    – Shubham Johri
    Dec 18 '18 at 7:26










  • $begingroup$
    thanks, i edited it
    $endgroup$
    – Lazar Ionut Radu
    Dec 18 '18 at 8:06










  • $begingroup$
    Looks correct to me
    $endgroup$
    – Shubham Johri
    Dec 18 '18 at 8:14
















5












$begingroup$


Using the digits $0$, $1$, $2$, $3$, and $4$, how many ten digit sequences can be written so
that the difference between any two consecutive digits is $1$?



I was wondering if my solution is right.



Let $a(n)$ be the number of n digit sequences that end with $0$ or $4$ so
that the difference between any two consecutive digits is $1$.



$b(n)$ be the number of n digit sequences that end with $1$ or $3$ so
that the difference between any two consecutive digits is $1$.



$c(n)$ be the number of n digit sequences that end with $2$ so
that the difference between any two consecutive digits is $1$.



$x(n)$ be the number of n digit sequences so
that the difference between any two consecutive digits is $1$.



$x(n) = a(n) + b(n) + c(n)$



$a(n) = b(n-1)$



$b(n) = a(n-1) + 2c(n-1)$



$c(n) = b(n-1)$



By substituting $a(n-1)$ and $c(n-1)$ in the formula for $b(n)$ we get $b(n) = 3b(n-2)$



We know that $b(1) = 2, b(2) = 4$.



The characteristic equation for this recurssion is $x^2-3 = 0$ with have the roots $3^{1/2}$ and $-3^{1/2}$, so $b(n) = A{(3^{1/2})}^{n} + B{(-3^{1/2})}^{n}$ where $A = {(3^{1/2}+2)}/{3}$ and $B = {(2-3^{1/2})}/{3}$. I think this is an integer.



We get $x(n) = 2b(n-1) + 3b(n-2)$ and by substituting we get something.










share|cite|improve this question











$endgroup$












  • $begingroup$
    You get $b(n)=3b(n-2)$
    $endgroup$
    – Shubham Johri
    Dec 18 '18 at 7:26










  • $begingroup$
    thanks, i edited it
    $endgroup$
    – Lazar Ionut Radu
    Dec 18 '18 at 8:06










  • $begingroup$
    Looks correct to me
    $endgroup$
    – Shubham Johri
    Dec 18 '18 at 8:14














5












5








5


2



$begingroup$


Using the digits $0$, $1$, $2$, $3$, and $4$, how many ten digit sequences can be written so
that the difference between any two consecutive digits is $1$?



I was wondering if my solution is right.



Let $a(n)$ be the number of n digit sequences that end with $0$ or $4$ so
that the difference between any two consecutive digits is $1$.



$b(n)$ be the number of n digit sequences that end with $1$ or $3$ so
that the difference between any two consecutive digits is $1$.



$c(n)$ be the number of n digit sequences that end with $2$ so
that the difference between any two consecutive digits is $1$.



$x(n)$ be the number of n digit sequences so
that the difference between any two consecutive digits is $1$.



$x(n) = a(n) + b(n) + c(n)$



$a(n) = b(n-1)$



$b(n) = a(n-1) + 2c(n-1)$



$c(n) = b(n-1)$



By substituting $a(n-1)$ and $c(n-1)$ in the formula for $b(n)$ we get $b(n) = 3b(n-2)$



We know that $b(1) = 2, b(2) = 4$.



The characteristic equation for this recurssion is $x^2-3 = 0$ with have the roots $3^{1/2}$ and $-3^{1/2}$, so $b(n) = A{(3^{1/2})}^{n} + B{(-3^{1/2})}^{n}$ where $A = {(3^{1/2}+2)}/{3}$ and $B = {(2-3^{1/2})}/{3}$. I think this is an integer.



We get $x(n) = 2b(n-1) + 3b(n-2)$ and by substituting we get something.










share|cite|improve this question











$endgroup$




Using the digits $0$, $1$, $2$, $3$, and $4$, how many ten digit sequences can be written so
that the difference between any two consecutive digits is $1$?



I was wondering if my solution is right.



Let $a(n)$ be the number of n digit sequences that end with $0$ or $4$ so
that the difference between any two consecutive digits is $1$.



$b(n)$ be the number of n digit sequences that end with $1$ or $3$ so
that the difference between any two consecutive digits is $1$.



$c(n)$ be the number of n digit sequences that end with $2$ so
that the difference between any two consecutive digits is $1$.



$x(n)$ be the number of n digit sequences so
that the difference between any two consecutive digits is $1$.



$x(n) = a(n) + b(n) + c(n)$



$a(n) = b(n-1)$



$b(n) = a(n-1) + 2c(n-1)$



$c(n) = b(n-1)$



By substituting $a(n-1)$ and $c(n-1)$ in the formula for $b(n)$ we get $b(n) = 3b(n-2)$



We know that $b(1) = 2, b(2) = 4$.



The characteristic equation for this recurssion is $x^2-3 = 0$ with have the roots $3^{1/2}$ and $-3^{1/2}$, so $b(n) = A{(3^{1/2})}^{n} + B{(-3^{1/2})}^{n}$ where $A = {(3^{1/2}+2)}/{3}$ and $B = {(2-3^{1/2})}/{3}$. I think this is an integer.



We get $x(n) = 2b(n-1) + 3b(n-2)$ and by substituting we get something.







combinatorics proof-verification






share|cite|improve this question















share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited Dec 20 '18 at 3:39









Alex Ravsky

42.2k32383




42.2k32383










asked Dec 18 '18 at 7:12









Lazar Ionut RaduLazar Ionut Radu

866




866












  • $begingroup$
    You get $b(n)=3b(n-2)$
    $endgroup$
    – Shubham Johri
    Dec 18 '18 at 7:26










  • $begingroup$
    thanks, i edited it
    $endgroup$
    – Lazar Ionut Radu
    Dec 18 '18 at 8:06










  • $begingroup$
    Looks correct to me
    $endgroup$
    – Shubham Johri
    Dec 18 '18 at 8:14


















  • $begingroup$
    You get $b(n)=3b(n-2)$
    $endgroup$
    – Shubham Johri
    Dec 18 '18 at 7:26










  • $begingroup$
    thanks, i edited it
    $endgroup$
    – Lazar Ionut Radu
    Dec 18 '18 at 8:06










  • $begingroup$
    Looks correct to me
    $endgroup$
    – Shubham Johri
    Dec 18 '18 at 8:14
















$begingroup$
You get $b(n)=3b(n-2)$
$endgroup$
– Shubham Johri
Dec 18 '18 at 7:26




$begingroup$
You get $b(n)=3b(n-2)$
$endgroup$
– Shubham Johri
Dec 18 '18 at 7:26












$begingroup$
thanks, i edited it
$endgroup$
– Lazar Ionut Radu
Dec 18 '18 at 8:06




$begingroup$
thanks, i edited it
$endgroup$
– Lazar Ionut Radu
Dec 18 '18 at 8:06












$begingroup$
Looks correct to me
$endgroup$
– Shubham Johri
Dec 18 '18 at 8:14




$begingroup$
Looks correct to me
$endgroup$
– Shubham Johri
Dec 18 '18 at 8:14










2 Answers
2






active

oldest

votes


















0












$begingroup$

Your approach looks good to me but you have to check the final result somehow. You can do that with 15 lines of code:



#include <iostream>
using namespace std;

int count(int startDigit, int length) {
if(startDigit < 0 || startDigit > 4) {
return 0;
}
if(length == 1)
return 1;
return count(startDigit - 1, length - 1) + count(startDigit + 1, length - 1);
}

int main() {
cout << count(1, 10) + count(2, 10) + count(3, 10) + count(4, 10);
}


...and the result is 567.






share|cite|improve this answer









$endgroup$





















    0












    $begingroup$


    here is your answer. Your approach was absolutely correct.






    share|cite|improve this answer









    $endgroup$













      Your Answer





      StackExchange.ifUsing("editor", function () {
      return StackExchange.using("mathjaxEditing", function () {
      StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
      StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
      });
      });
      }, "mathjax-editing");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "69"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      noCode: true, onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3044871%2fhow-many-sequnces-can-be-made-with-5-digits-so-that-the-difference-between-any-t%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0












      $begingroup$

      Your approach looks good to me but you have to check the final result somehow. You can do that with 15 lines of code:



      #include <iostream>
      using namespace std;

      int count(int startDigit, int length) {
      if(startDigit < 0 || startDigit > 4) {
      return 0;
      }
      if(length == 1)
      return 1;
      return count(startDigit - 1, length - 1) + count(startDigit + 1, length - 1);
      }

      int main() {
      cout << count(1, 10) + count(2, 10) + count(3, 10) + count(4, 10);
      }


      ...and the result is 567.






      share|cite|improve this answer









      $endgroup$


















        0












        $begingroup$

        Your approach looks good to me but you have to check the final result somehow. You can do that with 15 lines of code:



        #include <iostream>
        using namespace std;

        int count(int startDigit, int length) {
        if(startDigit < 0 || startDigit > 4) {
        return 0;
        }
        if(length == 1)
        return 1;
        return count(startDigit - 1, length - 1) + count(startDigit + 1, length - 1);
        }

        int main() {
        cout << count(1, 10) + count(2, 10) + count(3, 10) + count(4, 10);
        }


        ...and the result is 567.






        share|cite|improve this answer









        $endgroup$
















          0












          0








          0





          $begingroup$

          Your approach looks good to me but you have to check the final result somehow. You can do that with 15 lines of code:



          #include <iostream>
          using namespace std;

          int count(int startDigit, int length) {
          if(startDigit < 0 || startDigit > 4) {
          return 0;
          }
          if(length == 1)
          return 1;
          return count(startDigit - 1, length - 1) + count(startDigit + 1, length - 1);
          }

          int main() {
          cout << count(1, 10) + count(2, 10) + count(3, 10) + count(4, 10);
          }


          ...and the result is 567.






          share|cite|improve this answer









          $endgroup$



          Your approach looks good to me but you have to check the final result somehow. You can do that with 15 lines of code:



          #include <iostream>
          using namespace std;

          int count(int startDigit, int length) {
          if(startDigit < 0 || startDigit > 4) {
          return 0;
          }
          if(length == 1)
          return 1;
          return count(startDigit - 1, length - 1) + count(startDigit + 1, length - 1);
          }

          int main() {
          cout << count(1, 10) + count(2, 10) + count(3, 10) + count(4, 10);
          }


          ...and the result is 567.







          share|cite|improve this answer












          share|cite|improve this answer



          share|cite|improve this answer










          answered Dec 20 '18 at 16:35









          OldboyOldboy

          8,4801936




          8,4801936























              0












              $begingroup$


              here is your answer. Your approach was absolutely correct.






              share|cite|improve this answer









              $endgroup$


















                0












                $begingroup$


                here is your answer. Your approach was absolutely correct.






                share|cite|improve this answer









                $endgroup$
















                  0












                  0








                  0





                  $begingroup$


                  here is your answer. Your approach was absolutely correct.






                  share|cite|improve this answer









                  $endgroup$




                  here is your answer. Your approach was absolutely correct.







                  share|cite|improve this answer












                  share|cite|improve this answer



                  share|cite|improve this answer










                  answered Feb 1 at 4:10









                  Sarah janeSarah jane

                  1797




                  1797






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Mathematics Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      Use MathJax to format equations. MathJax reference.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3044871%2fhow-many-sequnces-can-be-made-with-5-digits-so-that-the-difference-between-any-t%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      How do I know what Microsoft account the skydrive app is syncing to?

                      When does type information flow backwards in C++?

                      Grease: Live!