Logo Search packages:      
Sourcecode: kbruch version File versions  Download package

unsigned short task::prim_factor_nr ( int  number = 1 ) [private]

returns the count number's prime factors

returns the count number's prime factors and stores the prime factors in the prim_fac_vektor vektor

Definition at line 512 of file task.cpp.

References PRIME_FACTOR::factor, PRIME_FACTOR::flag, primenumber::get_current(), primenumber::move_first(), primenumber::move_forward(), and prim_fac_vector.

Referenced by make_main_dn().

{
    unsigned int tmp_number = number;
    primenumber primenumber;
    Tprime_factor prim_fac_struct;

    /* delete all the prime factors of the old main denominator */
    prim_fac_vector.clear();

    /* test if we can find prime factors */
    for (primenumber.move_first(); primenumber.get_current() <= tmp_number;) {
        /* if the current selected prime number is a divisor */
        if (tmp_number % primenumber.get_current() != 0) {
            primenumber.move_forward(); /* no, test next one */
        } else {
            /* yes, we found a new prime factor; so first we use the divisor */
            tmp_number = int (tmp_number / primenumber.get_current());

            /* now we add the prime factor to our prime factor vector */
            prim_fac_struct.factor = primenumber.get_current();
            prim_fac_struct.flag = UNUSED;
            prim_fac_vector.push_back (prim_fac_struct);
        }
    }
#ifdef DEBUG
    PrimeFactorArray::iterator prim_fac_pointer = prim_fac_vector.begin();
    kDebug() << "Primfaktoren von: " << number;
    for (prim_fac_pointer = prim_fac_vector.begin();
            prim_fac_pointer != prim_fac_vector.end();
            ++prim_fac_pointer)
        kDebug() << (*prim_fac_pointer).factor;
    kDebug() << "Anzahl: " << prim_fac_vector.size();
#endif

    return prim_fac_vector.size();
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index