Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript Program for sum of arithmetic series using loop

// JavaScript program to find the sum of arithmetic series
// Function to find the sum of arithmetic series
function sumOfArithmeticSeries(firstTerm, commonDifference, noOfTerms) {
 var result = 0;
 for (let i=0; i<noOfTerms; i++)
 {
 result = result + firstTerm;
 firstTerm = firstTerm + commonDifference;
 }
 return result;
}

var firstTerm = 1;
var commonDifference = 2;
var noOfTerms = 5;
document.write("First Term: " + firstTerm + "<br>");
document.write("Common Difference: " + commonDifference + "<br>");
document.write("Number of Terms: " + noOfTerms + "<br>");
document.write("Sum of the arithmetic series: " + sumOfArithmeticSeries(firstTerm, commonDifference, noOfTerms));
Comment

PREVIOUS NEXT
Code Example
Javascript :: sort array based on subarray value 
Javascript :: delete all document fragments js 
Javascript :: what is container in angular 
Javascript :: onclick add and remove class using jquery 
Javascript :: formatting time for ical export 
Javascript :: toggleplay button javascript 
Javascript :: react js public folder image path search 
Javascript :: jsx children 
Javascript :: execute only once on multiple clicks javascript 
Javascript :: node_modules is not generated in docker 
Javascript :: django ajax json data become string 
Javascript :: find the minimum number in an array javascript 
Javascript :: pass function name as string javascript 
Javascript :: window handles 
Javascript :: modify an array in javascript using function method 
Javascript :: number of filters 
Javascript :: using multiple dropzones with formik field array 
Javascript :: angular date passed to donet care is a day less 
Javascript :: nodejs mysql set query timeout 
Javascript :: Plumsail - DataTable Populating Dropdown 
Javascript :: select inputs without specific type js 
Javascript :: json format in .net core 
Javascript :: js remove child with index 
Javascript :: Changing the value of a dropdown when the value of a number box changes in AngularJS 
Javascript :: Angular after click add active class and remove from siblings 
Javascript :: Json response reactnative fetch login data 
Javascript :: change useragent cypress test run 
Javascript :: Store input values in array javascript 
Javascript :: boilerplate functional component for DataGrid 
Javascript :: Variables In Self Invoking Function 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =