Untitled

mail@pastecode.io avatar
unknown
plain_text
6 months ago
608 B
0
Indexable
Never
 import java.util.*;
 public class Main 
 {
     public static void main(String[] arge){
         Scanner scr=new Scanner(System.in);
         int m=scr.nextInt();
         int n=scr.nextInt();
         int sum=0;
         int diff=0;
         int tot=0;
         for (int i=1;i<=n;i++){
             if(i%m==0){
                 sum=sum+i;
             }
         }
              for(int i=1;i<=n;i++){
                  if(i%m!=0){
                      diff=diff+i;
                  }
              }
              tot=diff-sum;
              System.out.println(tot);

                  }
              }
Leave a Comment