Cognizant interview question

2 Coding questions based on pattern and sequence