Question: Write a function called theSequence that takes a single integer parameter named n. This function should then calculate and return the n-th integer in
Write a function called theSequence that takes a single integer parameter named n. This function should then calculate and return the n-th integer in the sequence defined above. So, for example: printin(theSequence(1)); // Would output 1 printin(theSequence(2)); // Would output 1 printin(theSequence(3)); // Would output 1 printin(theSequence(4)); // Would output 3 printin(theSequence(5)); // Would output 5 printin(theSequence(6)); // Would output 9 printin(theSequence(7)); // Would output 17 printin(theSequence(7); // Would still output 17 printin(theSequence(7)); // Would always output 17 /l skipping ahead a few... printin(theSequence(37)); // Would output 1467182629 Your function must be able to support values of n arguments from 1 to 37. Your function should not include any hard-coded numbers, other than the number one. Meaning you can't have, for example, the number 31 or the number 1467182629 typed somewhere within your function.
Step by Step Solution
3.44 Rating (147 Votes )
There are 3 Steps involved in it
To solve this problem we need to identify the pattern in the sequence provided Heres the sequence ba... View full answer
Get step-by-step solutions from verified subject matter experts
