Epic Systems Interview Question
Software Engineer / DevelopersCountry: United States
Interview Type: Written Test
This is to determine sequence, a topic from discrete math.
We seek a_n, where
a_1 = -3 = -1 * 3
a_2 = 6 = 1 * 3 * 2
a_3 = -18 = -1 * 6 * 3
a_4 = 72 = 1 * 18 * 4
a_5 = -360 = -1 * 72 * 5
By inspection, the sequence is produced by
with initial condition n =1:
a_1 = -3
and subsequent sequence given by
a_n = (-1)**(n-1) * a_(n-1) * n for n > 2
Implemented in python:
{
import math
def a(n):
init = -3
pre = init
print pre
i = 2
while i < n + 1:
answer = (-1)**(i) * abs(pre) * i
print answer
pre = answer
i = i + 1
}
>>> a(6)
-3
6
-18
72
-360
2160
-3 x -2 = 6
- learner123 April 25, 20146 x -3 = -18
-18 x -4 = 72
72 x -5 = -360
-360 x -6 = 2160
so next number in the series is 2160.