//#(compile) c++; compiler:g132; options:-O3 -std=c++23; libs:-
// https://godbolt.org/z/dz75jr1rM
#include <iostream>
#include <thread>
#include <syncstream>
long fib(long n) { return n<=1 ? n : fib(n-1)+fib(n-2); }
void runFib(long von, long schritt, long bis) {
for (auto n=von; n<=bis; n+=schritt) {
std::osyncstream osync{ std::cout }; // Sync auf cout, solange osync existiert
osync << "fib("<<n<<")=" << fib(n) << '\n';
}
}
int main() {
std::jthread f40{ runFib, 1, 3, 40 };
std::jthread f41{ runFib, 2, 3, 41 };
std::jthread f42{ runFib, 3, 3, 42 };
}