Last active
January 30, 2016 19:51
-
-
Save unohee/ffe8ed5406e75c0fdad9 to your computer and use it in GitHub Desktop.
Infinity Series Prototype : coded version of Infinity Series
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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(); | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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