how to find formula that matches pattern

150 Views Asked by At

I have a pattern that I'm struggling to find the formula for.

For inputs of 0 - 3, the expected result is 0. For inputs 4 - 6, the expected result is 3.
7 - 9 should output 6. 10 - 12 should output 9. 13 - 15 should output 12. 16 - 18 should output 15. ... this pattern repeats ...

 0, 1, 2, 3 = 0
    4, 5, 6 = 3
    7, 8, 9 = 6
   10,11,12 = 9
   13,14,15 = 12
   16,17,18 = 15
   ...

I'm not as interested in the 0 - 3 part that doesn't "fit the pattern", I can code around that. It's the part of the pattern that repeats that I'm most interested in. How do I "convert" a pattern like this to a "formula"?

1

There are 1 best solutions below

2
On BEST ANSWER

Let $\div$ be the integer division operator, then $$a(n)=3\left(\left(n-1\right) \div 3\right)$$ fits the pattern.