-
multiples(limit, factors, union = True, intersection = False)
Returns a list of multiples under
limit
of any/all numbers infactors
.union (default :
True
): If true, returns list of all multiples of any of numbers infactors
.intersection (default :
False
): If true, returns list of multiples of all of numbers infactors
.If both
intersection
andunion
are simultaneously:a.
False
, then list of list of all multiples of each factor infactors
is returnedb.
True
, then throws an exception.Note: Even though,
multiples()
appears to show similar functionalities tofilter_seq()
, it is not so as we pass only a single parameter to the condition function while filtering which is not the case with multiples as we take multiple inputs inis_multiple()
. -
is_multiple(n, factors, all = true)
Returns whether
n
is a multiple of all/any of numbers infactors
all (default :
True
):-
If true, returns
True
ifn
is a multiple of all numbers infactors
-
Else if false, returns
True
ifn
is a multiple of any number infactors
-
-
sum_seq(seq)
Returns the sum of all numbers inseq
-
generate_seq(n, until = True, length = False, seq_type = "natural_no")
Returns a sequence of type
seq_type
of lengthn
or until the valuen
is approacheduntil (default :
True
): If true returns sequence until the no.n
is reached.length (default :
False
): If true returns firstn
numbers in the seq.seq_type (default :
"natural_no"
): Defines the type of the sequence required. Takes values:- "fibonacci"
- "natural_no"
- "triangular"
- "collatz"
- "prime"
- "even"
- "palindrome"
- "odd"
If both until and length are
False
, firstn
Fibonacci numbers are returned.If both until and length are
True
, method throws an exception. -
filter_seq(seq, condition = None, custom = None falsy = False)
Returns a list of values from
seq
obeying the givencondition
condition
(str): Can take values:- even
- palindrome
- prime
falsy
(bool): If true returns a list of values from seq not obeying the conditioncustom
: Pass a custom method which checks a condition.filter_seq()
then returns a list of values which obey the condition in the custom method -
even(n)
Returns true if
n
is even.
-
factors(nums, proper = True, separate = True, union = False, intersection = False)
Returns the factors of all numbers in
nums
.union (default :
True
): If true, returns list of all factors of any of numbers innums
.intersection (default :
False
): If true, returns list of factors of all of numbers innums
.If both
intersection
andunion
are simultaneously:a.
False
, then list of list of all factor of each no. innums
is returnedb.
True
, then throws an exception.proper (default : True): If true, returns all proper factors (all factors including 1 and
n
) ofn
else return improper factors. -
prime(n)
Returns True if
n
is prime else returns False -
max_value(seq)
Returns the maximum value in a sequence
seq
.
-
products(multipliers, num_of_multipliers = 2)
Returns the list of products of numbers from
multipliers
takennum_of_multipliers
at a time. -
palindrome(n)
Checks whether
n
is a palindrome or not.
-
least_common_multiple(nums)
Returns the LCM of all numbers in nums.
-
greatest_common_divisor(nums)
Returns the GCD of all numbers in nums.
-
power_num(n, power)
Returns the value of
n
to the powerpower
. -
power_seq(seq, power)
Returns the list of all numbers in the
seq
raised to the powerpower
-
nth_number(n, num_type = "natural", custom_type = None)
Returns the
n
thnum_type
numbernum_type
(default : "natural"): Type of nth number needed. Takes the values: "prime", "even", "odd", "palidrome"custom_type
(default : None): pass a function to check the type of number.nth_number()
then returns the nth number of type whose custom type is checked.
Uses the functions documented above
-
columns(grid)
Returns the columns of a grid.
-
rows(grid)
Returns the rows of a grid.
-
diagonals(grid)
Returns the elements along slants of a grid.
-
no_of_factors_seq(seq)
Returns the list of no. of factors of each value in a sequence.
-
first_n_digits(num, n)
Returns the list of the first
n
digits of a numbernum
-
size_seq(limits, type = "natural_nos")
Returns a list of sizes of all sequences having their limit in
limits
.type (default : "natural_nos"): Defines type of a seq. Can take the values:
- "fibonacci"
- "natural_no"
- "triangular"
- "collatz"
- "prime"
- "even"
- "palindrome"
- "odd"