Wednesday, January 13, 2010

CODIES 1.3

###### TREAT QUESTION ######

There is a concept of some magic numbers like we have numbers from 1 to some big number and we follow some iterations on the initial sequence of numbers: 1 2 3 4 5 6 7 8......

1) In first iteration we delete the numbers leaving one gap that is we delete numbers 2 4 6 8….. Therefore now the remaining numbers are 1 3 5 7 9 11 13 15 17 19................
2) In second iteration we delete numbers leaving two gaps, hence after it left no.s are 1 3 7 9 13 15 19 21……
3) Then we delete no.s leaving 3 gaps and hence left nos. are 1 3 7 13 15 19 25…….

The numbers which are never deleted are termed as magic number.
Write a function, given a number, that whether a number is a magic no. or not.


###### TREAT QUESTION ######