- #1
Russelluke
- 6
- 0
I'm not and expert in math and have only high school level math which has mostly faded from memory. I've been searching the net to see if there is an algorithm or something to derive a function from a given input and output sequence of numbers. I'm guessing you just have to do it by hand as one person said on a question answer site, using common sense and experience. But I don't have much ^^, please help.
This is the sequence:
...91,93,95...<46>...141,143,145,147...<96>...243,245,247,249...<46>...295,297,299...<182>...481,483,485...<46>...>>>
It starts from one and the there are three numbers as you can see with the space between the first set of number and the second being 46 numbers. After the 182 gap it's starts over again with gaps of 46, then 96 and so on, supposedly forever.
Forgive me if I'm not describing this problem too well but here goes. This is related to a programming/mathematics project I'm working on as a hobby but more maths than programming. So I'm not looking for the algorithm that produces that sequence which I can find on my own. And here's where I'm not even sure I know what it is I'm looking for but, say the numbers in that sequence are bad numbers that I don't want. So when I pick a random number, I want to first check to see if it belongs to that sequence without actually creating the sequence up to the number. So is there a function or equation that I can derive from the sequence that I could use to tell me whether any given number belongs to this sequence?
I don't know where to start but the result I'm looking for is something like this:
if the sequence was something simple like multiples of 3 (3,6,9,12,15,...) then to test if a given number belongs to the sequence I would use the following equation in my code:
if x mod 3 = 0: True
as in: if dividing the number by 3 produces no remainders then it is True it is a multiple of 3, I think?
I'm willing to work at it but could use some pointers and general help. Much appreciated.
Sorry for the long story but I hope that describes the problem well enough.--------------------------------------------------------------
I apologize for not being clear, I really didn't know how to express it.
If you take all the numbers from 1 up to say 1000 and put them in boxes like:
[1][2][3][4] etc
Then and then mark off the numbers in the following sequence:
91,93,95,141,143,145,147,243,245,247,249,295,297,299,481,483,485,
they follow a consistent pattern.
I think I was supposed to say it starts at 91 not 1 again sorry about the confusion. They are all odd numbers. The first three are 91,93,95 then there is a gap of 46 numbers(or boxes) before the numbers appear again which are 141,143,145,147 then a gap of 96 and they start again 243,245,247,249 and then back to the gap of 46 before they appear again at 295,297,299 then a gap of 182(which is twice the size of the 96 gap) before it starts over again in that same order of gaps and the same order for the length of each set.
So if I were to create an algorithm to create the sequence it should look like this(I don't know pseudocode but please bare with me):
let x = 89
while True:
...for length = 3:
...x = x + 2
...add x to sequence
...x = x + 46
...for length = 4:
...x = x + 2
...add x to sequence
...x = x + 96
...for length = 4:
...x = x + 2
...add x to sequence
...x = x + 182
That will generate the sequence to infinity. Assuming that these numbers are special in some way, if I wanted to test any random number to see if it belonged to the sequence then I could generate the sequence with that algorithm until the last number in the sequence is greater than or equal to the number I'm testing and see if the number is found in the sequence. That is too inefficient for a very large random number. So instead of generating the sequence with the algorithm I'm looking for something like an equation where I can put the number into the equation and see the result.
This is the sequence:
...91,93,95...<46>...141,143,145,147...<96>...243,245,247,249...<46>...295,297,299...<182>...481,483,485...<46>...>>>
It starts from one and the there are three numbers as you can see with the space between the first set of number and the second being 46 numbers. After the 182 gap it's starts over again with gaps of 46, then 96 and so on, supposedly forever.
Forgive me if I'm not describing this problem too well but here goes. This is related to a programming/mathematics project I'm working on as a hobby but more maths than programming. So I'm not looking for the algorithm that produces that sequence which I can find on my own. And here's where I'm not even sure I know what it is I'm looking for but, say the numbers in that sequence are bad numbers that I don't want. So when I pick a random number, I want to first check to see if it belongs to that sequence without actually creating the sequence up to the number. So is there a function or equation that I can derive from the sequence that I could use to tell me whether any given number belongs to this sequence?
I don't know where to start but the result I'm looking for is something like this:
if the sequence was something simple like multiples of 3 (3,6,9,12,15,...) then to test if a given number belongs to the sequence I would use the following equation in my code:
if x mod 3 = 0: True
as in: if dividing the number by 3 produces no remainders then it is True it is a multiple of 3, I think?
I'm willing to work at it but could use some pointers and general help. Much appreciated.
Sorry for the long story but I hope that describes the problem well enough.--------------------------------------------------------------
I apologize for not being clear, I really didn't know how to express it.
If you take all the numbers from 1 up to say 1000 and put them in boxes like:
[1][2][3][4] etc
Then and then mark off the numbers in the following sequence:
91,93,95,141,143,145,147,243,245,247,249,295,297,299,481,483,485,
they follow a consistent pattern.
I think I was supposed to say it starts at 91 not 1 again sorry about the confusion. They are all odd numbers. The first three are 91,93,95 then there is a gap of 46 numbers(or boxes) before the numbers appear again which are 141,143,145,147 then a gap of 96 and they start again 243,245,247,249 and then back to the gap of 46 before they appear again at 295,297,299 then a gap of 182(which is twice the size of the 96 gap) before it starts over again in that same order of gaps and the same order for the length of each set.
So if I were to create an algorithm to create the sequence it should look like this(I don't know pseudocode but please bare with me):
let x = 89
while True:
...for length = 3:
...x = x + 2
...add x to sequence
...x = x + 46
...for length = 4:
...x = x + 2
...add x to sequence
...x = x + 96
...for length = 4:
...x = x + 2
...add x to sequence
...x = x + 182
That will generate the sequence to infinity. Assuming that these numbers are special in some way, if I wanted to test any random number to see if it belonged to the sequence then I could generate the sequence with that algorithm until the last number in the sequence is greater than or equal to the number I'm testing and see if the number is found in the sequence. That is too inefficient for a very large random number. So instead of generating the sequence with the algorithm I'm looking for something like an equation where I can put the number into the equation and see the result.
Last edited: