/**
* Class to provide aritmathics services using Javascript
*
* @author : irfanudin ridho
* @email : irfan.ub@gmail.com
* @date : December 25, 2010
* @version : 1.0
*/
/**
* Constructor service
* @param start the first value of the series
* @param diff the difference between the values in the series
* @n how many value in the series
*/
function AritmathicSeries(start,diff,n){
this.data = new Array();
this.start = start;
this.diff = diff;
this.n = n;
}
this.data = new Array();
this.start = start;
this.diff = diff;
this.n = n;
}
/**
* method to get the series
* @return array of the series
*/
AritmathicSeries.prototype.getSeries = function(){
for(i=0;i<this.n;i++){
this.data[i] = this.start + (this.diff*i);
}
return this.data;
}
AritmathicSeries.prototype.getSeries = function(){
for(i=0;i<this.n;i++){
this.data[i] = this.start + (this.diff*i);
}
return this.data;
}
/**
* method to get the total sum of the individual value of
* the series.
* @return sum total summation of the series.
*/
AritmathicSeries.prototype.getSum = function(){
var sum = 0;
for(i=0;i<this.n;i++){
sum = sum+(this.start+(this.diff*i));
}
return sum;
}
AritmathicSeries.prototype.getSum = function(){
var sum = 0;
for(i=0;i<this.n;i++){
sum = sum+(this.start+(this.diff*i));
}
return sum;
}
No comments:
Post a Comment