fork download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. class Fibonacci {
  6. public:
  7. static vector<int> generateFibonacci(int n) {
  8. vector<int> fibSeries;
  9. int a = 0, b = 1;
  10.  
  11. for (int i = 0; i < n; i++) {
  12. fibSeries.push_back(a);
  13. int next = a + b;
  14. a = b;
  15. b = next;
  16. }
  17.  
  18. return fibSeries;
  19. }
  20. };
  21.  
  22. int main() {
  23. int n = 10;
  24. vector<int> fibSeries = Fibonacci::generateFibonacci(n);
  25.  
  26. for (int num : fibSeries) {
  27. cout << num << " ";
  28. }
  29.  
  30. return 0;
  31. }
  32.  
Success #stdin #stdout #stderr 0.01s 9024KB
stdin
Standard input is empty
stdout
Object: false error: did not understand #>
MessageNotUnderstood(Exception)>>signal (ExcHandling.st:254)
False(Object)>>doesNotUnderstand: #> (SysExcept.st:1448)
UndefinedObject>>executeStatements (prog:2)
stderr
./prog:7: parse error, expected '}'