xtd 0.2.0
Loading...
Searching...
No Matches
fibonacci_series.cpp

Shows how to use xtd::console, xtd::string classes.

#include <xtd/collections/generic/list>
#include <xtd/console>
using namespace xtd;
using namespace xtd::collections::generic;
auto fibonacci_series(int n) noexcept {
auto numbers = list {0};
auto a = 1, b = 1;
while (a < n) {
numbers.emplace_back(a);
std::swap(a, b);
b += a;
}
return numbers;
}
auto main() -> int {
console::write_line(string::join(", ", fibonacci_series(1000)));
}
// This code produces the following output :
//
// 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
Definition list.h:71
The xtd::collections::generic namespace contains interfaces and classes that define generic collectio...
Definition comparer.h:15
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10