Skip to content

Instantly share code, notes, and snippets.

@unohee
Last active January 30, 2016 19:51
Show Gist options
  • Select an option

  • Save unohee/ffe8ed5406e75c0fdad9 to your computer and use it in GitHub Desktop.

Select an option

Save unohee/ffe8ed5406e75c0fdad9 to your computer and use it in GitHub Desktop.
Infinity Series Prototype : coded version of Infinity Series
#include "InfinitySeries.hpp"
void InfinitySeries::generate(int size){
series.assign(size,0);//populate array first
index = 0; //set index for the array.
//start from fundamental. numbers only shows the relative relationships(interval) but absolute relationship.
do{
//first two step.
if(index==0){
series.at(0) = 0;
}
if(index==1){
series.at(1) = (series[0] + 1);
}
index ++;
}while(index < 2);
for(int i = 1; i < size/2; i ++){
series[2*i] = series[2*i-2] - (series[i] - series[i-1]);
series[2*i+1] = series[2*i-1] + (series[i] - series[i-1]);
index++;
}
for(unsigned int i = 0; i < series.size(); i++){
std::cout<< i+1 <<" Series : "<<series[i]<<std::endl;
}
}
int InfinitySeries::get_val(int column){
return series.at(column);
}
int InfinitySeries::getSize(){
return series.size();
}
#include <iostream>
#include <vector>
class InfinitySeries{
public:
// InfinitySeries();
// ~InfinitySeries();
void generate(int size);
int get_val(int column);
int getSize();
private:
std::vector<int>series;
int index;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment