Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rnd.next(long long n) produces a periodic sequence when n is a power of 2 #165

Open
Weierstras-s opened this issue Oct 19, 2022 · 0 comments

Comments

@Weierstras-s
Copy link

It seems that the period is $32768\cdot n$ when $n=2^k$.

The output of the following code is 1.

#include <bits/stdc++.h>
using namespace std;

int main(int argc, char *argv[]){
    registerGen(argc, argv, 1);

    const long long n = 2;
    
    string s, t;
    for (int i = 0; i < 32768 * n; ++i)
        s += rnd.next(n) + '0';
    for (int i = 0; i < 32768 * n; ++i)
        t += rnd.next(n) + '0';
    cout << (s == t);
    return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant