r/maths • • 5d ago

💡 Puzzle & Riddles is this sequence possible to write as a formula?

1,2,4,5,7,8,10,11,13,14....

basically all multiples of 3 are missing.

12 Upvotes

22 comments sorted by

9

u/uTRexAap 4d ago

f(x) = (6x-3-(-1)^x)/4 works

3

u/The_Banana_Monk 4d ago edited 4d ago

much apprecated captain. i got to a similar version but it didnt quite work and i wasnt sure if i was on the right path.

2

u/WhiteEmails 3d ago

Can I ask your reasoning for it? I had the same (-1)^x idea but couldn't manage to find the rest and I'm interested now.

2

u/FormulaDriven 3d ago • Heartwarming

The numbers come in pairs, and if you look at the first of each pair, you'll notice:

f(1) = 1

f(3) = 4

f(5) = 7

...

steps of 3 for every increase of 2 in the index, so that suggests f(n) = 3n / 2 + something, and we soon see that f(n) = 3n / 2 - 1/2 or (3n - 1) / 2 works.

Now for the second in the pair we find for even n, f(n) = (3n - 2) / 2 works, eg f(2) = 4.

Summary so far:

f(n) = (3n - 1) / 2 when n is odd

f(n) = (3n - 2) / 2 when n is even

So now we need something that is 1 when n is odd, 2 when n is even. 3/2 + (-1)n / 2 does that.

So f(n) = (3n - 3/2 - (-1)n / 2) / 2

which can be tidied to

f(n) = (6n - 3 - (-1)n ) / 4

1

u/WhiteEmails 3d ago

TY so much!

3

u/SupermarketUseful519 4d ago

I’d say the easiest way is to look at the differences between the numbers. It’s +1, then +2, then +1 again, and so on.
So you can start with 1 and just keep adding 1 and 2 alternately.
If you want an actual formula for the nth term, you could use:
a(n) = n + floor((n - 1)/2)
Or just take all positive integers and skip the multiples of 3. If you’re doing it in code, n % 3 != 0 does the job.
Depends on whether you want to describe the pattern, calculate a particular term, or generate the sequence.

1

u/The_Banana_Monk 4d ago

its actually +1 +1 +2 +1 +2. the start of the sequence matters too. thanks for the help, one of the other comments gave me a proper formula

2

u/SupermarketUseful519 4d ago

Well, the sequence you actually posted starts at 1, so the differences between consecutive terms are +1, +2, +1, +2…
If you’re counting from zero, then just define a₀ = 1. In that case, aₙ = 1 + floor(3n/2) works for n ≥ 0.
My original formula uses n ≥ 1 and gives exactly the same sequence.
It’s just a matter of indexing, not a different pattern.

1

u/The_Banana_Monk 4d ago

i see

1

u/Consistent-Annual268 4d ago

Zero is a multiple of 3 so if you're starting from zero you already have a first term that doesn't comply with your rule.

2

u/berwynResident 4d ago

a(n) = 3 + a(n-2)

1

u/The_Banana_Monk 4d ago

whats a?

2

u/berwynResident 4d ago

It's a recursive function. I should have specified the degenerate values a(0) =1, a(1) = 2

5

u/matt7259 4d ago

Yes, in several ways.

1

u/Another_Little_Star 4d ago

can i use trig?
so ceil(-|(cos((n)*pi/3))|)+1
every 3 digits you have 2 followed 1s and one 0, you can adjust each value by multiplying everything by n
so (-1)n and cos(npi) and sin(npi) are periodic, in cos(n) you can change the period to every three digits or anything, by adjusting with absolute value and ceiling you get what you desired

1

u/The_Banana_Monk 4d ago

fancy

2

u/Another_Little_Star 4d ago

nevermind it fills n=3 with 0, n=6 with 0 doesn't exclude them

1

u/mH48124 4d ago

[ (3n-1)/2 ]

1

u/Kyng5199 2d ago

Well, we're going up by 3, every 2 terms of the sequence. So, let's consider a(n) = 3n/2:

1.5, 3, 4.5, 6, 7.5, 9, ...

To get the sequence we need, we have to subtract 0.5 from the odd terms, and 1 from the even terms.

Dealing with the 0.5 is easy. Consider b(n) = (3n - 1)/2:

1, 2.5, 4, 5.5, 7, 8.5, ...

Now, we just need to subtract an additional 0.5 from the even terms. (1 + (-1)^n) will be 2 when n is even, and 0 when n is odd. So, we can set c(n) = (3n - 1)/2 - (1 + (-1)^n)/4:

1, 2, 4, 5, 7, 8, ...

Or, as an optional last step, if you want to tidy up c(n) a bit:

c(n) = (3n - 1)/2 - (1 + (-1)^n)/4
c(n) = (6n - 2)/4 - (1 + (-1)^n)/4
c(n) = (6n - 2 - 1 - (-1)^n)/4
c(n) = (6n - 3 - (-1)^n)/4

Hope that helps!

1

u/smitra00 4d ago

Solution for lazy people with access to computer algebra systems:

Define

f(x) = 1 + 2 x + 4 x^2 + 5 x^3 + 7 x^4 + 8 x^5 + 10 x^6 + 11 x^7 + 13 x^8 + 14 x^9 + 16 x^10...

Computing the [5,5] Padé approximant using the terms up to x^10 yields:

https://en.wikipedia.org/wiki/Pad%C3%A9_approximant

f(x) = (1 + x + x^2)/(1 -x - x^2 + x^3)

The sum of the degrees of numerator and denominator is 5 which is less than 10, therefore we can be confident that this is the exact answer. Expanding in partial fractions yields:

f(x) = 1/4 1/(x+1) + 3/4 1/(x-1) + 3/2 1/(x-1)^2

We then see that the coefficient of x^n is:

1/4 (-1)^n - 3/4 + 3/2 (n+1) = 1/4 (-1)^n + 3/4 + 3/2 n

This then yields the numbers in the sequence with the first term having the index n = 0.