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 

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

1 Expert Approved Answer
Step: 1 Unlock

To solve this problem we need to identify the pattern in the sequence provided Heres the sequence ba... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!