Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 8. Броене на кратни на 3 (for)
- # Въведете две цели числа – начало и край.
- # Използвайте for, за да преброите колко числа между тях (включително) се делят на 3.
- num_start = int(input("Please enter integer: "))
- num_end = int(input("Please enter integer: "))
- counter = 0
- flag = False
- while True:
- if num_start < num_end:
- flag = True
- for i in range(num_start, num_end + 1):
- if i % 3 == 0:
- counter += 1
- break
- elif num_start == num_end:
- if num_start % 3 == 0:
- print("The numbers are equal and divisible by 3.")
- else:
- print("The numbers are equal and not divisible by 3.")
- break
- else:
- print("The first number cannot be greater than the second number")
- num_start = int(input("Please enter correct data: "))
- num_end = int(input("Please enter correct data: "))
- if flag:
- print("Between numbers " + str(num_start) + " and " + str(num_end) + " тhere are " + str(counter) +
- " numbers that are divisible by 3.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement