num_theory.arithmetic_progression ================================= .. py:module:: num_theory.arithmetic_progression Functions --------- .. autoapisummary:: num_theory.arithmetic_progression.arithmetic_progression Module Contents --------------- .. py:function:: arithmetic_progression(a, d, n, compute_sum=False, nth_term=False) Generate terms of an arithmetic progression (AP), compute the nth term, or calculate the sum of the first n terms. :param a: The first term of the AP. :type a: float :param d: The common difference between consecutive terms. :type d: float :param n: The number of terms, the term to compute, or the term index. :type n: int :param compute_sum: If True, computes the sum of the first n terms. Default is False. :type compute_sum: bool, optional :param nth_term: If True, computes the nth term of the AP instead of generating terms. Default is False. :type nth_term: bool, optional :returns: - If `compute_sum` and `nth_term` are both False, returns a list of the first n terms of the AP. - If `nth_term` is True, returns the nth term as a float. - If `compute_sum` is True, returns the sum of the first n terms as a float. - If both `nth_term` and `compute_sum` is True, it will return the nth term as a float. :rtype: list or float .. rubric:: Examples >>> arithmetic_progression(a=2, d=3, n=5) [2, 5, 8, 11, 14] >>> arithmetic_progression(a=2, d=3, n=5, compute_sum=True) 40.0 >>> arithmetic_progression(a=2, d=3, n=5, nth_term=True) 14 >>> arithmetic_progression(a=1, d=2, n=5, nth_term=True) 9