Question: Write a function that takes a positive integer N and then calculates and displays the sum of the first N odd integers. For example, if

Write a function that takes a positive integer N and then calculates and displays
the sum of the first N odd integers. For example, if N is 4, your function should
display the value 16, which is 1+3+5+7.(4 points)
/* Test program*/
function TestSumOddIntegers(){
console.log("sumOddintegers(0)->"+ sumOddintegers(0)+"(should be 0)");
console.log("sumOddintegers(1)->"+ sumOddintegers(1)+"((should be 1)");
console.log("sumOddIntegers(4)->"+ sumOddintegers(4)+"((should be 16)");
console log("sumOddlntegers(100)->"" sumOddintegers(100)+"((should be 10000)");
}
Write a function that takes a positive integer N

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!