Help determining an equation that describes a pattern

  • Thread starter Thread starter Ouka
  • Start date Start date
Ouka
Messages
1
Reaction score
0
Hi all,

Been a looooong time since I had to use calculus for anything, but I distinctly remember failing this section of the course miserably. I can describe a pattern but for the life of me I can't write an equation that describes the pattern I see.

For a program I'm wrtting for work I need to write an equation that will describe the following pattern:

If n = 1 to 93 then x = 1
(diff = 92)
If n = 94 to 183 then x = 2
(diff = 89)
If n = 184 to 276 then x = 3
(diff = 92)
If n = 277 to 366 then x = 4
(diff = 89)
and so on and so forth...

ANy help would be greatly appriciated. I know it's possible to write a sigma equation to describe this sort of pattern, but like I said I failed this section of my calculus course miserably! Never thought I'd actually use it again!

--Ouka
 
Physics news on Phys.org
Is there some reason you need to actually create an equation to describe this? Since you're writing a computer program, why can't you do something like this?

Code:
def f(n):
	acc = 0
	i = 0
	x = 0
	while (acc < n):
		if (i == 0):
			acc = acc + 93
		else:
			acc = acc + 90
		
		i = (i + 1) % 2
		x = x + 1
		
	return x

- Warren
 
Back
Top