Given n, a and d as the number of terms, first term and common difference respectively of an Arthimetic Series. Find the sum of the series upto nth term.
 
Example 1:
Input: 5 1 3
Output: 35
Explanation: Series upto 5th term is
1 4 7 10 13, so sum will be 35.
Example 2:
Input: 3 1 2
Output: 9
Example: Series upto 3rd term is 
1 3 5, so sum will be 9.
 
Your Task:
You don't need to read or print anything. Your task is to complete the function sum_of_ap() which takes n, a and d as input parameter and returns the sum of the series.
 
Expected Time Complexity: O(1)
Expected Space Complexity: O(1)
 
Constranits:
1 <= n, a, d <= 100

Source: geeksforgeeks | Difficulty: EASY
Tags: Mathematics

Starter code: #User function Template for python3

class Solution:
	def sum_of_ap(self, n, a, d):
		# Code here

Solutions:
class Solution:

	def sum_of_ap(self, n, a, d):
		return int(a * n + n * (n - 1) * d / 2)


class Solution:

	def sum_of_ap(self, n, a, d):
		li = []
		for i in range(1, n + 1):
			li.append(a + (i - 1) * d)
		return sum(li)


import math

class Solution:

	def sum_of_ap(self, n, a, d):
		return math.floor(n / 2 * (2 * a + (n - 1) * d))


class Solution:

	def sum_of_ap(self, n, a, d):
		c = a
		l = 0
		for i in range(1, n + 1):
			l += c
			c += d
		return l


class Solution:

	def sum_of_ap(self, n, a, d):
		l = []
		l.append(a)
		for i in range(1, n):
			l.append(l[i - 1] + d)
		sum = 0
		for i in range(len(l)):
			sum = sum + l[i]
		return sum


class Solution:

	def sum_of_ap(self, n, a, d):
		s = 0
		for i in range(n):
			s += a
			a += d
		return s


class Solution:

	def sum_of_ap(self, n, a, d):
		l = a + (n - 1) * d
		return (a + l) * n // 2


class Solution:

	def sum_of_ap(self, n, a, d):
		s = []
		for i in range(n):
			s.append(a + i * d)
		return sum(s)


class Solution:

	def sum_of_ap(self, n, a, d):
		an = a + (n - 1) * d
		sum = n * (a + an) // 2
		return sum


class Solution:

	def sum_of_ap(self, n, a, d):
		tot = [a]
		t = a
		for i in range(n - 1):
			t += d
			tot.append(t)
		return sum(tot)


class Solution:

	def sum_of_ap(self, n, a, d):
		sn = n * (2 * a + (n - 1) * d) // 2
		return sn


class Solution:

	def sum_of_ap(self, n, a, d):
		N = a + (n - 1) * d
		return n * (a + N) // 2


class Solution:

	def sum_of_ap(self, n, a, d):
		N = n
		A = a
		D = d
		return int(N / 2 * (2 * A + (N - 1) * D))


class Solution:

	def sum_of_ap(self, n, a, d):
		fn = a
		res = fn
		for i in range(n - 1):
			fn += d
			res += fn
		return res


class Solution:

	def sum_of_ap(self, n, a, d):
		x = n / 2 * (2 * a + d * (n - 1))
		return round(x)


class Solution:

	def sum_of_ap(self, n, a, d):
		a1 = a + (n - 1) * d
		return (a1 + a) * n // 2


class Solution:

	def sum_of_ap(self, n, a, d):
		lst = []
		for i in range(n):
			c = a + d * i
			lst.append(c)
		return sum(lst)


class Solution:

	def sum_of_ap(self, n, a, d):
		f = [a]
		e = a
		for i in range(n - 1):
			e += d
			f.append(e)
		return sum(f)


class Solution:

	def sum_of_ap(self, n, a, d):
		sum = 0
		for i in range(1, n + 1):
			sum += a + (i - 1) * d
		return sum


class Solution:

	def sum_of_ap(self, n, a, d):
		list_of_numbers = []
		while n != 0:
			list_of_numbers.append(a)
			a = a + d
			n -= 1
		j = 0
		for i in list_of_numbers:
			j = j + i
		return j


class Solution:

	def sum_of_ap(self, n, a, d):
		s = a
		num = a
		for i in range(n - 1):
			num += d
			s += num
		return s


class Solution:

	def sum_of_ap(self, n, a, d):
		no = a
		for i in range(n - 1):
			a += d
			no += a
		return no