Exemplo n.º 1
0
int find_period(int t, int lb, int ub)
{
    int i;
    for(i = 1; i < t; i++)
    {
        if(t%i)
            continue;
        if(check_period(i, lb, ub))
            return i;
    }
    return t;
}
Exemplo n.º 2
0
int main(void)
{
    RandomState   *state;
    int           i;
    unsigned long rand;

    state = N(RandomCreate)(1);
    for (i = 0; i < 10000; i++) {
	rand = N(Random)(state);
    }
    printf("After 10000 iterations: %lu (%lu expected): %s\n",
	   rand, state->check,
	   rand - state->check ? "*INCORRECT*" : "CORRECT");
    N(RandomDestroy)(state);

    printf("Checking periods...\n");
    check_period(1);
    check_period(2);
    check_period(31415926);
    
    return 0;
}
Exemplo n.º 3
0
//max_dig_pell was destroyed accidentally. 
//check wolfram page if necessary
int main()
{
    vector<int> vroot;
    vector<I64Pair> vp;
    i64 nmax = 0;
    check_period(5, 2, vroot);
    int cnt =0;
    max_dig_pell(5, vroot, vp);
    for(unsigned int i = 0; i < vp.size(); ++i){
        i64 np = vp[i].first;
        i64 nq = vp[i].second;
        if((np%5==2) || (np%5==3)){
            printf("%lld %lld\n", np, nq);
            nmax += nq;
            ++cnt;
            if(cnt ==13)break;
        }
    }
    printf("%lld\n", nmax-1);
}