[Tutor] 2 quick questions...

Sean 'Shaleh' Perry shalehperry@attbi.com
Wed, 02 Jan 2002 12:47:18 -0800 (PST)


On 02-Jan-2002 vip333d@yahoo.com wrote:
> Dear Tutor,
>  I want to make a somewhat simple program, that finds
> for me complex numbers, and does it by some algorithm
> that says:
> if N==2**(k-1)*(2**k-1)
> [NOT: N==2**(k-1)*(2**(k-1))]
> while 2**k-1 is a Number wich divides only with 1 and
> itself.
> I have got over the problem of finding numbers that
> divide only by themself and 1, but I have 2 problems:
> 1) to say that k can be any number, I tried saying k =
> range(x,y), but it didn't work. How can I?
> 2) I have all the numbers wich devide by 1 and
> themselves on a list. How can I see if the phrase:
> 2**k-1 is in the list?
> 
> please don't do all the work for me, I just wanna
> practice.
> 

Use parens to be more clear in your math.  (2**k)-1 or 2**(k-1) for instance.

l = [1,2,3,4]

3 in l
1

the 'in' operator tells you if an item is in a sequence.

'a' in 'Sean'
1