Method: Calc::Q#lfactor

Defined in:
ext/calc/q.c

#lfactor(other) ⇒ Calc::Q

Smallest prime factor in first specified number of primes

If n is nonzero and abs(n) has a prime factor in the first m primes (2, 3, 5, …), then n.lfactor(m) returns the smallest such factor. Otherwise it returns 1.

Examples:

Calc::Q(2**32 + 1).lfactor(116) #=> Calc::Q(641)

Parameters:

Returns:



1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
# File 'ext/calc/q.c', line 1619

static VALUE
cq_lfactor(VALUE self, VALUE other)
{
    NUMBER *qother, *qresult;
    setup_math_error();

    qother = value_to_number(other, 1);
    qresult = qlowfactor(DATA_PTR(self), qother);
    qfree(qother);
    return wrap_number(qresult);
}