this is the algorithm upon which ihave formed my code…if(n>1) then, if atleast 1 odd number is present in the sequence then the output is 1 .if all the numbers are even then output is 2. if n=1,then the output is the input itself…but im getting wrong anwer …sum1 pls help…

@prem_93 : your algorithm is incorrect. check this test case n=2,a[0]=3,a[1]=6. expected ans=3 not 1,but your ans=1, and also n=2,a[0]=4,a[1]=8 excepted ans=4 not 2. so it is wrong. if you have still doubt in algorithm please leave me a comment,i will be always here to help you.

2 Likes