Timer is Running

Part of it.
Submissions: 18   Accuracy:


  Difficulty: Medium   Marks: 4

A given series 3, 5, 9, 11, 15, 21, 29, ... and so on. You need to identify the pattern and determine whether the input number  ( ) is a part of the given series or not. If yes then return "Yes", otherwise "No".

Example 1:

Input: n = 9
Output: Yes
Explanation: 9 is the part of
the sequence.

​Example 2:

Input: n = 8
Output: No
Explanation: 8 is not the part
of the sequence

Your Task:  
You don't need to read input or print anything. Your task is to complete the function isPart() which takes as inputs and returns the answer.

Expected Time Complexity: O(sqrt(n))
Expected Auxiliary Space: O(1)

1 ≤ n ≤ 106

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Diksha Singhal
Author: diksha1812

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.