Welcome, guest | Sign In | My Account | Store | Cart
#Author: A.Polino

def is_power2(num):

	'states if a number is a power of two'

	return num != 0 and ((num & (num - 1)) == 0)

Diff to Previous Revision

--- revision 1 2010-12-23 11:28:48
+++ revision 2 2010-12-23 11:29:38
@@ -1,3 +1,5 @@
+#Author: A.Polino
+
 def is_power2(num):
 
 	'states if a number is a power of two'

History