How can I determine if a number is a part of arithmetic sequence












0












$begingroup$


Sorry if this is a simple question, I am not so good in mathematics and trying to start understanding it better. So thanks is advance.



I have this sequence - 0,1,5,6,10,11,15,16,20,21....
Which is n numbers and then a gap of n+1.
What I need is a way to get a random number and check if it is part of the sequence.



I see that I can check the last number and see if it is (0,1,5,6) but this will be true only for this sequence. So I need more generic way.



Thanks
Shani



edit
The sequence starts from 0
n = 2
Then we start with n numbers (0,1) skip n+1 numbers (2,3,4) then include n numbers (5,6) , skip n+1 (7,8,9)...










share|cite|improve this question











$endgroup$












  • $begingroup$
    I know the sequence it is in this case n and then a gap of n+1. Thanks
    $endgroup$
    – shannoga
    Mar 19 '16 at 9:58










  • $begingroup$
    i don't understand the definition of the sequence. You say "$n$ numbers and then a gap of $n+1$" but your sequence looks like $2$ numbers and then a gap of $4$. What is $n$? Can you write out the first few terms if $n$ were, say, $3$?
    $endgroup$
    – lulu
    Mar 19 '16 at 10:29










  • $begingroup$
    Ok. Edited my question. Thanks
    $endgroup$
    – shannoga
    Mar 19 '16 at 10:35










  • $begingroup$
    Got it. So, in this case, the "consecutive strings" start with elements of the progression ${0,5,10,15,dots}$. Given a random $m$ find the nearest multiple of $5$ less than or equal to $m$....then we need $m$ to either be this multiple or $1$ greater. Similar for general $n$.
    $endgroup$
    – lulu
    Mar 19 '16 at 10:37










  • $begingroup$
    The terms of an arithmetic sequence have a common difference, so this is not an arithmetic sequence.
    $endgroup$
    – N. F. Taussig
    Sep 7 '17 at 8:53
















0












$begingroup$


Sorry if this is a simple question, I am not so good in mathematics and trying to start understanding it better. So thanks is advance.



I have this sequence - 0,1,5,6,10,11,15,16,20,21....
Which is n numbers and then a gap of n+1.
What I need is a way to get a random number and check if it is part of the sequence.



I see that I can check the last number and see if it is (0,1,5,6) but this will be true only for this sequence. So I need more generic way.



Thanks
Shani



edit
The sequence starts from 0
n = 2
Then we start with n numbers (0,1) skip n+1 numbers (2,3,4) then include n numbers (5,6) , skip n+1 (7,8,9)...










share|cite|improve this question











$endgroup$












  • $begingroup$
    I know the sequence it is in this case n and then a gap of n+1. Thanks
    $endgroup$
    – shannoga
    Mar 19 '16 at 9:58










  • $begingroup$
    i don't understand the definition of the sequence. You say "$n$ numbers and then a gap of $n+1$" but your sequence looks like $2$ numbers and then a gap of $4$. What is $n$? Can you write out the first few terms if $n$ were, say, $3$?
    $endgroup$
    – lulu
    Mar 19 '16 at 10:29










  • $begingroup$
    Ok. Edited my question. Thanks
    $endgroup$
    – shannoga
    Mar 19 '16 at 10:35










  • $begingroup$
    Got it. So, in this case, the "consecutive strings" start with elements of the progression ${0,5,10,15,dots}$. Given a random $m$ find the nearest multiple of $5$ less than or equal to $m$....then we need $m$ to either be this multiple or $1$ greater. Similar for general $n$.
    $endgroup$
    – lulu
    Mar 19 '16 at 10:37










  • $begingroup$
    The terms of an arithmetic sequence have a common difference, so this is not an arithmetic sequence.
    $endgroup$
    – N. F. Taussig
    Sep 7 '17 at 8:53














0












0








0





$begingroup$


Sorry if this is a simple question, I am not so good in mathematics and trying to start understanding it better. So thanks is advance.



I have this sequence - 0,1,5,6,10,11,15,16,20,21....
Which is n numbers and then a gap of n+1.
What I need is a way to get a random number and check if it is part of the sequence.



I see that I can check the last number and see if it is (0,1,5,6) but this will be true only for this sequence. So I need more generic way.



Thanks
Shani



edit
The sequence starts from 0
n = 2
Then we start with n numbers (0,1) skip n+1 numbers (2,3,4) then include n numbers (5,6) , skip n+1 (7,8,9)...










share|cite|improve this question











$endgroup$




Sorry if this is a simple question, I am not so good in mathematics and trying to start understanding it better. So thanks is advance.



I have this sequence - 0,1,5,6,10,11,15,16,20,21....
Which is n numbers and then a gap of n+1.
What I need is a way to get a random number and check if it is part of the sequence.



I see that I can check the last number and see if it is (0,1,5,6) but this will be true only for this sequence. So I need more generic way.



Thanks
Shani



edit
The sequence starts from 0
n = 2
Then we start with n numbers (0,1) skip n+1 numbers (2,3,4) then include n numbers (5,6) , skip n+1 (7,8,9)...







sequences-and-series






share|cite|improve this question















share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited Mar 19 '16 at 10:34







shannoga

















asked Mar 19 '16 at 9:40









shannogashannoga

10113




10113












  • $begingroup$
    I know the sequence it is in this case n and then a gap of n+1. Thanks
    $endgroup$
    – shannoga
    Mar 19 '16 at 9:58










  • $begingroup$
    i don't understand the definition of the sequence. You say "$n$ numbers and then a gap of $n+1$" but your sequence looks like $2$ numbers and then a gap of $4$. What is $n$? Can you write out the first few terms if $n$ were, say, $3$?
    $endgroup$
    – lulu
    Mar 19 '16 at 10:29










  • $begingroup$
    Ok. Edited my question. Thanks
    $endgroup$
    – shannoga
    Mar 19 '16 at 10:35










  • $begingroup$
    Got it. So, in this case, the "consecutive strings" start with elements of the progression ${0,5,10,15,dots}$. Given a random $m$ find the nearest multiple of $5$ less than or equal to $m$....then we need $m$ to either be this multiple or $1$ greater. Similar for general $n$.
    $endgroup$
    – lulu
    Mar 19 '16 at 10:37










  • $begingroup$
    The terms of an arithmetic sequence have a common difference, so this is not an arithmetic sequence.
    $endgroup$
    – N. F. Taussig
    Sep 7 '17 at 8:53


















  • $begingroup$
    I know the sequence it is in this case n and then a gap of n+1. Thanks
    $endgroup$
    – shannoga
    Mar 19 '16 at 9:58










  • $begingroup$
    i don't understand the definition of the sequence. You say "$n$ numbers and then a gap of $n+1$" but your sequence looks like $2$ numbers and then a gap of $4$. What is $n$? Can you write out the first few terms if $n$ were, say, $3$?
    $endgroup$
    – lulu
    Mar 19 '16 at 10:29










  • $begingroup$
    Ok. Edited my question. Thanks
    $endgroup$
    – shannoga
    Mar 19 '16 at 10:35










  • $begingroup$
    Got it. So, in this case, the "consecutive strings" start with elements of the progression ${0,5,10,15,dots}$. Given a random $m$ find the nearest multiple of $5$ less than or equal to $m$....then we need $m$ to either be this multiple or $1$ greater. Similar for general $n$.
    $endgroup$
    – lulu
    Mar 19 '16 at 10:37










  • $begingroup$
    The terms of an arithmetic sequence have a common difference, so this is not an arithmetic sequence.
    $endgroup$
    – N. F. Taussig
    Sep 7 '17 at 8:53
















$begingroup$
I know the sequence it is in this case n and then a gap of n+1. Thanks
$endgroup$
– shannoga
Mar 19 '16 at 9:58




$begingroup$
I know the sequence it is in this case n and then a gap of n+1. Thanks
$endgroup$
– shannoga
Mar 19 '16 at 9:58












$begingroup$
i don't understand the definition of the sequence. You say "$n$ numbers and then a gap of $n+1$" but your sequence looks like $2$ numbers and then a gap of $4$. What is $n$? Can you write out the first few terms if $n$ were, say, $3$?
$endgroup$
– lulu
Mar 19 '16 at 10:29




$begingroup$
i don't understand the definition of the sequence. You say "$n$ numbers and then a gap of $n+1$" but your sequence looks like $2$ numbers and then a gap of $4$. What is $n$? Can you write out the first few terms if $n$ were, say, $3$?
$endgroup$
– lulu
Mar 19 '16 at 10:29












$begingroup$
Ok. Edited my question. Thanks
$endgroup$
– shannoga
Mar 19 '16 at 10:35




$begingroup$
Ok. Edited my question. Thanks
$endgroup$
– shannoga
Mar 19 '16 at 10:35












$begingroup$
Got it. So, in this case, the "consecutive strings" start with elements of the progression ${0,5,10,15,dots}$. Given a random $m$ find the nearest multiple of $5$ less than or equal to $m$....then we need $m$ to either be this multiple or $1$ greater. Similar for general $n$.
$endgroup$
– lulu
Mar 19 '16 at 10:37




$begingroup$
Got it. So, in this case, the "consecutive strings" start with elements of the progression ${0,5,10,15,dots}$. Given a random $m$ find the nearest multiple of $5$ less than or equal to $m$....then we need $m$ to either be this multiple or $1$ greater. Similar for general $n$.
$endgroup$
– lulu
Mar 19 '16 at 10:37












$begingroup$
The terms of an arithmetic sequence have a common difference, so this is not an arithmetic sequence.
$endgroup$
– N. F. Taussig
Sep 7 '17 at 8:53




$begingroup$
The terms of an arithmetic sequence have a common difference, so this is not an arithmetic sequence.
$endgroup$
– N. F. Taussig
Sep 7 '17 at 8:53










2 Answers
2






active

oldest

votes


















0












$begingroup$

Okay generally speaking you need to have a formula for the terms of the sequence. In your case the formula seems to be
$$a_{2n} = 5n; , ; a_{2n+1} = 5n+1$$
However it might as well be a completely different formula, this is completely possible!



The basic notion is to try and find the relations between the terms and express them properly.






share|cite|improve this answer









$endgroup$





















    0












    $begingroup$

    Your description of your sequence is perhaps not very practical when it comes to calculations. But the procedure for producing elements of the sequence is a periodic one. You take an input sequence of natural numbers and pick two and then skips $n$ and repeat. This means that you consume $n+2$ integers from the input sequence for each round through the algorithm.



    You can reformulate the produce by working in chunks. You take a chunk of $n+2$ integers and emit the first two.



    Now it shouldn't be too hard to see that the $(j+1)$th chunk consist of the numbers $(n+2)j, (n+2)j+1, dots, (n+2)j+n+1$ of which we pick the first two numbers. This results in that we see that the numbers we produce is $(n+2)j$ and $(n+2)j+1$.



    So the question is transformed to the question whether a random number $r$ can be written as $r = (n+2)j$ or $r-1=(n+2)j$ for some integer $j$. That is if $r/(n+2)$ or $(r-1)/(n+2)$ are integers (we call that $r$ or $r-1$ is divisible by $n+2$).






    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%2f1704143%2fhow-can-i-determine-if-a-number-is-a-part-of-arithmetic-sequence%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$

      Okay generally speaking you need to have a formula for the terms of the sequence. In your case the formula seems to be
      $$a_{2n} = 5n; , ; a_{2n+1} = 5n+1$$
      However it might as well be a completely different formula, this is completely possible!



      The basic notion is to try and find the relations between the terms and express them properly.






      share|cite|improve this answer









      $endgroup$


















        0












        $begingroup$

        Okay generally speaking you need to have a formula for the terms of the sequence. In your case the formula seems to be
        $$a_{2n} = 5n; , ; a_{2n+1} = 5n+1$$
        However it might as well be a completely different formula, this is completely possible!



        The basic notion is to try and find the relations between the terms and express them properly.






        share|cite|improve this answer









        $endgroup$
















          0












          0








          0





          $begingroup$

          Okay generally speaking you need to have a formula for the terms of the sequence. In your case the formula seems to be
          $$a_{2n} = 5n; , ; a_{2n+1} = 5n+1$$
          However it might as well be a completely different formula, this is completely possible!



          The basic notion is to try and find the relations between the terms and express them properly.






          share|cite|improve this answer









          $endgroup$



          Okay generally speaking you need to have a formula for the terms of the sequence. In your case the formula seems to be
          $$a_{2n} = 5n; , ; a_{2n+1} = 5n+1$$
          However it might as well be a completely different formula, this is completely possible!



          The basic notion is to try and find the relations between the terms and express them properly.







          share|cite|improve this answer












          share|cite|improve this answer



          share|cite|improve this answer










          answered Mar 19 '16 at 10:44









          christina_gchristina_g

          125213




          125213























              0












              $begingroup$

              Your description of your sequence is perhaps not very practical when it comes to calculations. But the procedure for producing elements of the sequence is a periodic one. You take an input sequence of natural numbers and pick two and then skips $n$ and repeat. This means that you consume $n+2$ integers from the input sequence for each round through the algorithm.



              You can reformulate the produce by working in chunks. You take a chunk of $n+2$ integers and emit the first two.



              Now it shouldn't be too hard to see that the $(j+1)$th chunk consist of the numbers $(n+2)j, (n+2)j+1, dots, (n+2)j+n+1$ of which we pick the first two numbers. This results in that we see that the numbers we produce is $(n+2)j$ and $(n+2)j+1$.



              So the question is transformed to the question whether a random number $r$ can be written as $r = (n+2)j$ or $r-1=(n+2)j$ for some integer $j$. That is if $r/(n+2)$ or $(r-1)/(n+2)$ are integers (we call that $r$ or $r-1$ is divisible by $n+2$).






              share|cite|improve this answer









              $endgroup$


















                0












                $begingroup$

                Your description of your sequence is perhaps not very practical when it comes to calculations. But the procedure for producing elements of the sequence is a periodic one. You take an input sequence of natural numbers and pick two and then skips $n$ and repeat. This means that you consume $n+2$ integers from the input sequence for each round through the algorithm.



                You can reformulate the produce by working in chunks. You take a chunk of $n+2$ integers and emit the first two.



                Now it shouldn't be too hard to see that the $(j+1)$th chunk consist of the numbers $(n+2)j, (n+2)j+1, dots, (n+2)j+n+1$ of which we pick the first two numbers. This results in that we see that the numbers we produce is $(n+2)j$ and $(n+2)j+1$.



                So the question is transformed to the question whether a random number $r$ can be written as $r = (n+2)j$ or $r-1=(n+2)j$ for some integer $j$. That is if $r/(n+2)$ or $(r-1)/(n+2)$ are integers (we call that $r$ or $r-1$ is divisible by $n+2$).






                share|cite|improve this answer









                $endgroup$
















                  0












                  0








                  0





                  $begingroup$

                  Your description of your sequence is perhaps not very practical when it comes to calculations. But the procedure for producing elements of the sequence is a periodic one. You take an input sequence of natural numbers and pick two and then skips $n$ and repeat. This means that you consume $n+2$ integers from the input sequence for each round through the algorithm.



                  You can reformulate the produce by working in chunks. You take a chunk of $n+2$ integers and emit the first two.



                  Now it shouldn't be too hard to see that the $(j+1)$th chunk consist of the numbers $(n+2)j, (n+2)j+1, dots, (n+2)j+n+1$ of which we pick the first two numbers. This results in that we see that the numbers we produce is $(n+2)j$ and $(n+2)j+1$.



                  So the question is transformed to the question whether a random number $r$ can be written as $r = (n+2)j$ or $r-1=(n+2)j$ for some integer $j$. That is if $r/(n+2)$ or $(r-1)/(n+2)$ are integers (we call that $r$ or $r-1$ is divisible by $n+2$).






                  share|cite|improve this answer









                  $endgroup$



                  Your description of your sequence is perhaps not very practical when it comes to calculations. But the procedure for producing elements of the sequence is a periodic one. You take an input sequence of natural numbers and pick two and then skips $n$ and repeat. This means that you consume $n+2$ integers from the input sequence for each round through the algorithm.



                  You can reformulate the produce by working in chunks. You take a chunk of $n+2$ integers and emit the first two.



                  Now it shouldn't be too hard to see that the $(j+1)$th chunk consist of the numbers $(n+2)j, (n+2)j+1, dots, (n+2)j+n+1$ of which we pick the first two numbers. This results in that we see that the numbers we produce is $(n+2)j$ and $(n+2)j+1$.



                  So the question is transformed to the question whether a random number $r$ can be written as $r = (n+2)j$ or $r-1=(n+2)j$ for some integer $j$. That is if $r/(n+2)$ or $(r-1)/(n+2)$ are integers (we call that $r$ or $r-1$ is divisible by $n+2$).







                  share|cite|improve this answer












                  share|cite|improve this answer



                  share|cite|improve this answer










                  answered Aug 8 '17 at 7:43









                  skykingskyking

                  14.3k1929




                  14.3k1929






























                      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%2f1704143%2fhow-can-i-determine-if-a-number-is-a-part-of-arithmetic-sequence%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

                      Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

                      ComboBox Display Member on multiple fields

                      Is it possible to collect Nectar points via Trainline?