1132 Multiples of 13

SemiColon
By -
0
URI Online Judge | 1132

Multiples of 13

Write a program that reads two integer numbers X and Y and calculate the sum of all number not divisible by 13 between them, including both.

Input

The input file contains 2 integer numbers X and Y without any order.

Output

Print the sum of all numbers between X and Y not divisible by 13, including them if it is the case.
Input SampleOutput Sample
100
200
13954



Solution:
#include<stdio.h>
int main()
{
    int a,b,i,sum=0;
    scanf("%d %d",&a,&b);
    if(a<b)
        {
        for(i=a;i<=b;i++){
        if (i%13!=0){
            sum+=i;
        }
      }
    }
    else if(a>b)
        {
        for(i=b;i<=a;i++){
        if (i%13!=0){
            sum+=i;
        }
      }
    }
 printf("%d\n",sum);

    return 0;
}


Tags:

Post a Comment

0Comments

Post a Comment (0)