Final answer:
The sum of numbers divisible by both 3 and 5 between 0 and 100 is 315.
Step-by-step explanation:
Simple Python program to find and sum the numbers divisible by both 3 and 5 within the given range. The program iterates through each number from 0 to 100, checks if it is divisible by both 3 and 5, and if so, adds it to the total sum. visible by both 3 and 5 is printed.
# Python program to find the sum of numbers divisible by both 3 and 5
def find_sum():
total_sum = 0
for num in range(101):
if num % 3 == 0 and num % 5 == 0:
total_sum += num
return total_sum
# Calling the function to get the final result
result = find_sum()
# Displaying the final result
print("The sum of numbers divisible by both 3 and 5 between 0 and 100 is:", result)
The program iterates through numbers from 0 to 100 and checks for divisibility by both 3 and 5 using the modulo operator (%). If a number meets both conditions, it is added to the total sum. The final sum is then printed as the result.
The sum of numbers divisible by both 3 and 5 between 0 and 100 is found to be 315. The program effectively identifies and accumulates the relevant numbers, providing a clear and concise solution to the problem.