Find the sum of the first 10 numbers that are divisible by 3 and 9.
Sample Output
495
def result(N):
#iterating vode starting from 0 to num
for num in range(N):
# creating if condition for assigning numbers diviseble by 3 and 9
if num % 3 == 0 and num % 9 == 0:
print(str(num) + " ", end = "")
else:
pass
# Driver code
if __name__ == "__main__":
# number we want added here
N = int(input())
# Calling function
result(N)
Comments
Leave a comment