Ejemplo n.º 1
0
void main(int argc, char **argv) {
    if (argc < 2) {
        printf("[ERROR] Not enough args: %s [n]\n", argv[0]);
        exit(1);
    }

    prime_factors(atoi(argv[1]));
}
Ejemplo n.º 2
0
int main(){
    int n,*ptr;
    ptr = &n;
    printf("Enter the number :");
    scanf("%d", ptr);
    prime_factors(*ptr);
    return 0;
}
Ejemplo n.º 3
0
Archivo: 047.c Proyecto: pqhieu/shovel
int main()
{
    int count = 0;
    int i;
    for (i = 2 * 3 * 5 * 7; count < 4; ++i)
        count = prime_factors(i) >= 4 ? count + 1 : 0;

    printf("%d\n", i - 4);
    return 0;
}
Ejemplo n.º 4
0
 // splits n into a list of powers 2^a 2^b 2^c 3^d 5^e...
 // exponents are limited by available kernels,
 // if no kernel for prime is available, exponent will be 0, interpret as 1.
 std::vector<pow> factor(size_t n) const {
     std::vector<pow> out, factors = prime_factors(n);
     for(auto f = factors.begin() ; f != factors.end() ; f++) {
         if(std::find(primes.begin(), primes.end(), f->base) != primes.end()) {
             // split exponent into reasonable parts.
             auto qs = stages(*f);
             // use smallest radix first
             std::copy(qs.rbegin(), qs.rend(), std::back_inserter(out));
         } else {
             // unsupported prime.
             for(size_t i = 0 ; i != f->exponent ; i++)
                 out.push_back(pow(f->base, 0));
         }
     }
     return out;
 }
Ejemplo n.º 5
0
 std::string desc() const {
     std::ostringstream o;
     o << "FFT(";
     // sizes
     for(auto n = sizes.begin() ; n != sizes.end() ; n++) {
         if(n != sizes.begin()) o << " x ";
         o << *n;
         auto fs = prime_factors(*n);
         if(fs.size() > 1) {
             o << '=';
             for(auto f = fs.begin() ; f != fs.end() ; f++) {
                 if(f != fs.begin()) o << '*';
                 o << *f;
             }
         }
     }
     o << ")";
     return o.str();
 }
Ejemplo n.º 6
0
int primitive_root(int m, prime_holder& prim) {
	int phi = euler_phi(prim.factor_integer(m));
	auto phi_factors = prime_factors(prim.factor_integer(phi));
	return primitive_root(m, phi, phi_factors);
}
Ejemplo n.º 7
0
std::set<int> kth_roots_of_unity(int m, int k, prime_holder& prim) {
	int lam = carmichael_lambda(prim.factor_integer(m));
	auto lam_factors = prime_factors(prim.factor_integer(lam));
	int g = primitive_root_of_unity(m, lam, lam_factors);
	return kth_roots_of_unity(m, k, lam, g);
}
Ejemplo n.º 8
0
int primitive_root_of_unity(int m, prime_holder& prim) {
	int lam = carmichael_lambda(prim.factor_integer(m));
	auto lam_factors = prime_factors(prim.factor_integer(lam));
	return primitive_root_of_unity(m, lam, lam_factors);
}