
#1
Feb2612, 02:09 PM

P: 7

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. 



#2
Feb2612, 04:23 PM

P: 144

I find the specifications of this sequence rather unclear. One guess, disregarding your cryptical sentence "it starts from one...", is that we are just talking about 14 different values modulo 390. If not, it would be informative if you could clearly include some numbers that does not fit that pattern.




#3
Feb2612, 04:32 PM

P: 799

The awesome Online Encyclopedia of Integer Sequences is a great resource for this type of question.
https://oeis.org/ Your particular sequence isn't specified clearly enough for anyone to know what numbers are in the sequence. You can't just say, "It starts with x, y, and z and then there are 46 other numbers ..." and expect anyone to know what the sequence is. 



#4
Feb2612, 05:19 PM

P: 7

How do you find the function that describes this sequence?I search for it on that site but it picked up no results. 



#5
Feb2612, 05:44 PM

P: 799

It's still unclear what the sequence of gaps is. You have 46, 96, 46, 182 ...
Is there a pattern or algorithm for the gaps? 



#6
Feb2612, 06:14 PM

P: 7

But I think it's best if I just say here is the sequence 91,93,95,141,143,145,147,243,245,247,249,295,297,2 99,481,483,485,...up to infinity Ignore everything else including the algorithm and try to see the pattern the sequence follows. All I need is to find and equation to use for testing if a number belongs to this sequence. If I knew a bit about maths I wouldn't have confused everyone but I'm trying to change that. 



#7
Feb2612, 06:26 PM

P: 7

91,93,95,141,143,145,147,243,245,247,249,295,297,2 99,481,483,485,... Thank you for pointing out the need for clarification I was very unclear the way I described it and yes the starting point was totally wrong it's not 1 but 91. I hope that helps a bit, if it does I would much appreciate any further help. Thanks again 



#8
Feb2812, 04:40 AM

P: 144

OK, if there is nothing else to this sequence, your code to check x for inclusion would be:
S = list of the 14 first numbers in the sequence. y = x mod 390 if y in S then: YES else: NO 



#9
Feb2812, 05:03 AM

P: 7

It works!!! The solution seems so simple it's almost embarrassing. But before I say anything else, THANK YOU NORWEGIAN! I'm still fiddling with a calculator and pen and paper but I simply cannot figure out how you got it. If I had to guess I'd say it's got something to do with factors or multiples of some property of the first iteration of the sequence? I dinno, but if your still around I would kill to know. Thanks again. 



#10
Feb2812, 05:11 AM

P: 7

Ok I figured out where the 390 comes from.
The length of each iteration of the algorithm is 390(from 91 to 481). So it's the difference between the 1st number in the sequence and the 15th. Yet I know that the mod operator calculates the remainder. I can't yet understand how it works in this equation.  I think I'm getting warmer, so far I've established this much but not 100% sure if it's correct. There are two types of integer sequences. One is where the algorithm modifies itself, as in if the algorithm takes a value from the list it's creating to create the next value like the Fibonacci sequence. The other is where the algorithm works independent of the sequence it's creating so the length between the first number in the sequence and the first number of the next run of the algorithm will always be the same. Having identified that this sequence is of the second type you only need to list the number in one run of the algorithm and also note the length of integers between the first run and second. Then the equation to test for inclusion will always be: list = numbers in first run of algorithm. x = random number y = difference between first number in first run and first number in second run z = x mod y if z in list: True else: False Is all of that correct, if so I'll save it somewhere as I'll be using it allot in future. One more long shot question, is it possible to combine two or more sequence and use the same or similar method to test for inclusion? 


Register to reply 
Related Discussions  
What is a function that describes motion in a circular path?  Introductory Physics Homework  8  
prove the lorentzian function describes resonant behavior  Advanced Physics Homework  2  
Need example of a continuous function map cauchy sequence to noncauchy sequence  Calculus & Beyond Homework  1  
[matlab] I just want to plot a function that describes position as a function of time  Math & Science Software  2  
Is it possible to find function that describes irrational things?  Linear & Abstract Algebra  20 