In: Computer Science
Solve the following question by using python language
In range of 1-10000 if the numbers are divisible by n1 increase count by 1 , if the number is divisible by n2 increase count by 2, and if the number are divisible by n3 increase the count by 3
if none of the above conditions match for the number, increase count by the number.
n1=10 +17
n2=50 +21
n3=100 +9
Here is the answer for your question in Python Programming Language.
Kindly upvote if you find the answer helpful.
NOTE : I have taken simple if statements instead of if else because if one number is divide by all n1,n2,n3 or by any two of n1,n2 and n3 then using if else will increment count for only one condition.
####################################################################
CODE :
n1 = 10 + 17 if flag == 0: |
####################################################################
SCREENSHOTS :
Please see the screenshots of the code below for the indentations of the code. As python is a language of indentations kindly check the indentations of the code before execution.
############################################################################
OUTPUT :
Any doubts regarding this can be explained with pleasure :)