Website Summary Files Commits Branches @commit @diff @stats
path: root / Week13 / Exercise14.cpp
blob: 5a7f5ddbc10bb882320c405ddadc0c45c29e474d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>

const unsigned LEHMER_a = 16807;
const unsigned LEHMER_m = ((unsigned long)1 << 31) - 1;

void lehmerPrint(unsigned i, unsigned N, unsigned Xk) {
	if (i >= N) {
		std::cout << Xk << std::endl;
		return;
	}

	if (i > 0)
		std::cout << Xk << ' ';

	lehmerPrint(i + 1, N, (LEHMER_a * Xk) % LEHMER_m);
}

int main()
{
	unsigned seed, N;
	std::cin >> seed >> N;

	lehmerPrint(0, N, seed);

	return 0;
}