Write a javascript program to find sum of first n even numbers
Answers
Answered by
2
JavaScript-:
include <iostream> using namespace std; int main() { int n1, n2; cout << "Enter two numbers: "; cin >> n1 >> n2; while(n1 != n2) { if(n1 > n2) n1 -= n2; else n2 -= n1; } cout << "HCF = " << n1; return 0;
PLZZ follow me:O:O:O:O:O:-D
include <iostream> using namespace std; int main() { int n1, n2; cout << "Enter two numbers: "; cin >> n1 >> n2; while(n1 != n2) { if(n1 > n2) n1 -= n2; else n2 -= n1; } cout << "HCF = " << n1; return 0;
PLZZ follow me:O:O:O:O:O:-D
Answered by
4
Hi
function sunOfFirstNEventNumbers(range) {
let total = 0;
for (let i = 0; i <= range; i++) {
if (i % 2 === 0) total += i;
}
console.log(total);
}
sunOfFirstNEventNumbers(10);
Attachments:
Similar questions
Chemistry,
7 months ago
Environmental Sciences,
7 months ago
Physics,
7 months ago
Physics,
1 year ago
Math,
1 year ago
Math,
1 year ago
Social Sciences,
1 year ago