Advertisement
programusy

n = int(input("Podaj liczbe n: ")) b=1 p = n%2 n = n//2 while(n>0): c = n%2 if(c!=p):

Feb 19th, 2024
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.15 KB | None | 0 0
  1. n = int(input("Podaj liczbe n: "))
  2.  
  3. b=1
  4. p = n%2
  5. n = n//2
  6. while(n>0):
  7. c = n%2
  8. if(c!=p):
  9. b=b+1
  10. p=c
  11. n=n//2
  12. print(b)
  13.  
Tags: zajonc pyton
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement