Home > database >  Write a program to print the sum of 1 to n. While calculating sum omits the numbers which are multip
Write a program to print the sum of 1 to n. While calculating sum omits the numbers which are multip

Time:03-20

Please help me with this I'm not able to omit number of multiple x

CodePudding user response:

Keywords such as for and continue shouldn't be capitalized:

If you're trying to find the sum of numbers that are not multiples of x then you can try this:

total = 0
n = int(input("Enter n: "))
x = int(input("Enter x: "))
for i in range(0,n 1): 
    if(i%x==0): 
        continue  
    total  = i
print(total)
  • Related