# help in my sequence

• Feb 8th 2011, 11:34 AM
mido22
help in my sequence
(2,4,8,16,32,64,128,256,512,1024,......)

if i have a number i want to know if it is in the sequence or not
but i don't want the way which i will divide the number by 2 till i found it 2 or not i want a function from one or two steps to know if this number is from sequence or not
• Feb 8th 2011, 11:38 AM
e^(i*pi)
Take the log using base 2. If the answer is an integer than your number is in the sequence
• Feb 8th 2011, 11:46 AM
mido22
Quote:

Originally Posted by e^(i*pi)
Take the log using base 2. If the answer is an integer than your number is in the sequence

thx but what meant by log
• Feb 8th 2011, 11:50 AM
Plato
Look at \$\displaystyle 2^n\$.
• Feb 8th 2011, 11:50 AM
e^(i*pi)
Your sequences is \$\displaystyle u_n = 2^n\$. By log I mean logarithm which is the inverse of exponentiation. \$\displaystyle \log_2(x) = \log_2(2^n) = n\$ where x is the number you're wondering whether or not is in sequence
• Feb 8th 2011, 11:53 AM
mido22
thx this will help me alot
thx also plato but i think the second method is easier
• Feb 9th 2011, 03:57 AM
HallsofIvy
That's very strange! You say that you do not know what a logarithm is but you think it will be easier to take the logarithm?

If you really do not know about logarithms (especially taking the logarithm, base 2) I would recommend repeatedly dividing by 2. If you eventually arrive at 1 without any fractions, the number is a power of 2.
• Feb 9th 2011, 04:20 AM
mido22
Quote:

Originally Posted by HallsofIvy
That's very strange! You say that you do not know what a logarithm is but you think it will be easier to take the logarithm?

If you really do not know about logarithms (especially taking the logarithm, base 2) I would recommend repeatedly dividing by 2. If you eventually arrive at 1 without any fractions, the number is a power of 2.

i searched for lagorithm and learned it thx very much