Computer Science, asked by parvejkhan3303, 1 year ago

Write a javascript program to find sum of first n even numbers

Answers

Answered by ShivVedant
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
Answered by Anonymous
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