Interview Question: 2^n – 1 divide by 7


Q: n is a none-negative numbers, in order to let tex_a9973c04ccf3c7ed4be19df22022e2cc Interview Question: 2^n - 1 divide by 7 algorithms beginner bit hacks brute force implementation interview questions math programming languages python tricks divides perfectly 7, characterise n.

A: tex_a9973c04ccf3c7ed4be19df22022e2cc Interview Question: 2^n - 1 divide by 7 algorithms beginner bit hacks brute force implementation interview questions math programming languages python tricks in binary representation is n ones. And 7 in binary is 111. The n has to be multiples of 3 in order for tex_af6556883f4df6cc17ebd9d1c6279c4b Interview Question: 2^n - 1 divide by 7 algorithms beginner bit hacks brute force implementation interview questions math programming languages python tricks to be zero.

The following python script proves this by output the first then n (excluding zero because it is so obvious)

#!/usr/bin/python

cnt = 0
n = 1

while 1:
	if (2**n - 1) % 7 == 0:
		cnt += 1
		print n
		if cnt > 10: break
	n += 1

It will output 3, 6, 9, 12 … 33. tex_dc81441c43f1d8405fd57f131dbf55f1 Interview Question: 2^n - 1 divide by 7 algorithms beginner bit hacks brute force implementation interview questions math programming languages python tricks can be replaced by bit logics operation tex_e946cc9b90780ae5c6641f89065831bd Interview Question: 2^n - 1 divide by 7 algorithms beginner bit hacks brute force implementation interview questions math programming languages python tricks , which is a lot faster.

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
315 words
Last Post: N Queen Problem in Back Tracing, Bit-logics
Next Post: Heart of Equations

The Permanent URL is: Interview Question: 2^n – 1 divide by 7

Leave a Reply