Guess the Sequence

Submitted By:
david

Difficulty:
Medium

Tags:
math, integers

Instructions:
Figure out the sequence by looking at the problem code below. Then write a method to return items in the sequence given the number of the term. Note that your problem should also handle the 0th term all the way to the 9th term.

Hidden Code:
There is hidden code with assertions that is also being run to test out your code.

Code:
def sequence(n)
  ___
end

assert_equal sequence(1), 1
assert_equal sequence(2), 1
assert_equal sequence(3), 4
assert_equal sequence(4), 1
assert_equal sequence(5), 9
assert_equal sequence(6), 5

Your Solution

Ruby 1.9.3

Back to Problems