-
Notifications
You must be signed in to change notification settings - Fork 2
/
1101.js
52 lines (47 loc) · 902 Bytes
/
1101.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');
let [x, y] = lines.shift().split(" ");
let X = parseInt(x);
let Y = parseInt(y);
let i;
let text = "";
let sum = 0;
while(true){
if(X <= 0 || Y <= 0){
return;
}
if (X > Y) {
i = Y;
for(i; i <= X; i++){
if(i == Y){
text = text + i;
sum += i;
}
else
{text = text + " " + i;
sum += i;}
}
console.log(`${text} Sum=${sum}`)
}
else if(Y > X) {
i = X;
for(i; i <= Y; i++){
if(i == X){
text = text + i;
sum += i;
}
else
{ text = text + " " + i;
sum += i;}
}
console.log(`${text} Sum=${sum}`)
}
else if (X == Y){
console.log(`${X} Sum=${X}`);
}
[x, y] = lines.shift().split(" ");
X = parseInt(x);
Y = parseInt(y);
text = "";
sum = 0;
}