Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

URI/BEE problem no-1101 solution in Java

import java.util.Scanner;
public class Main{
    public static void main (String[] args) {
        int M,N,i,j,sum = 0;
        Scanner obj = new Scanner(System.in);
        
        for(i = 1; i <= 3; i++){
            M = obj.nextInt();
            N = obj.nextInt();
            
            for(j = N,sum = 0; j <= M; j++){
                if(N <= 0){
                    System.exit(1);
                }else{
                    System.out.printf("%d ", j);
                    sum += j;
                }
                
            }
            System.out.println("Sum=" + sum);
        }
        
    }
}
Source by www.beecrowd.com.br #
 
PREVIOUS NEXT
Tagged: #problem #solution #Java
ADD COMMENT
Topic
Name
4+3 =