giulio98/xlcost-single-prompt huggingface dataset:
# repeated unit divisibility | to find least value of k ; to check n is coprime or not ; to store r ( k ) mod n and 10 ^ k mod n value ; 
def repUnitValue(n):
    if (n % 2 == 0 or n % 5 == 0):
        return 0
    rem = 1
    power = 1
    k = 1
    while (rem % n != 0):
        k += 1
        power = power * 10 % n
        rem = (rem + power) % n
    return k


n = 13
print(repUnitValue(n))

# Expected output:
6
# first n natural can be divided into two sets with given difference and co | python3 code to determine whether numbers 1 to n can be divided into two sets such that absolute difference between sum of these two sets is m and these two sum are co - prime ; function that returns boolean value on the basis of whether it is possible to divide 1 to n numbers into two sets that satisfy given conditions . ; initializing total sum of 1 to n numbers ; since ( 1 ) total_sum = sum_s1 + sum_s2 and ( 2 ) m = sum_s1 - sum_s2 assuming sum_s1 > sum_s2 . solving these 2 equations to get sum_s1 and sum_s2 ; total_sum = sum_s1 + sum_s2 and therefore ; if total sum is less than the absolute difference then there is no way we can split n numbers into two sets so return false ; check if these two sums are integers and they add up to total sum and also if their absolute difference is m . ; now if two sum are co - prime then return true , else return false . ; if two sums don 't add up to total  sum or if their absolute difference  is not m, then there is no way to  split n numbers, hence return false ; 
def __gcd(a, b):
    return a if (b == 0)else __gcd(b, a % b)


def isSplittable(n, m):
    total_sum = (int)((n * (n + 1)) / 2)
    sum_s1 = int((total_sum + m) / 2)
    sum_s2 = total_sum - sum_s1
    if (total_sum < m):
        return False
    if (sum_s1 + sum_s2 == total_sum and sum_s1 - sum_s2 == m):
        return (__gcd(sum_s1, sum_s2) == 1)
    return False


n = 5
m = 7
if (isSplittable(n, m)):
    print("Yes")
else:
    print("No")

# Expected output:
Yes
# making zero array by decrementing pairs of adjacent | python3 implementation of the above approach ; converting array element into number ; check if divisible by 11 ; 
def isPossibleToZero(a, n):
    num = 0
    for i in range(n):
        num = num * 10 + a[i]
    return (num % 11 == 0)


arr = [0, 1, 1, 0]
n = len(arr)
if (isPossibleToZero(arr, n)):
    print("YES")
else:
    print("NO")

# Expected output:
YES
# blum integer | function to cheek if number is blum integer ; to store prime numbers from 2 to n ; if prime [ i ] is not changed , then it is a prime ; update all multiples of p ; to check if the 
def isBlumInteger(n):
    prime = [True] * (n + 1)
    i = 2
    while (i * i <= n):
        if (prime[i]):
            for j in range(i * 2, n + 1, i):
                prime[j] = False
        i = i + 1
    for i in range(2, n + 1):
        if (prime[i]):
            if ((n % i == 0) and ((i - 3) % 4) == 0):
                q = int(n / i)
                return (q != i and prime[q] and (q - 3) % 4 == 0)
    return False


n = 249
if (isBlumInteger(n)):
    print("Yes")
else:
    print("No")

# Expected output:
Yes
# program to calculate value of ncr | python 3 program to calculate the value of ncr ; returns factorial of n ; 
def fact(n):
    res = 1
    for i in range(2, n + 1):
        res = res * i
    return res

def nCr(n, r):
    return (fact(n) / (fact(r) * fact(n - r)))


n = 5
r = 3
print(int(nCr(n, r)))

# Expected output:
10
# program to print the sum of the given nth term | python3 program to illustrate ... summation of series ; function to calculate sum of series ; sum of n terms is n ^ 2 ; 

import math


def summingSeries(n):
    return math .pow(n, 2)


n = 100
print("The sum of n term is: ", summingSeries(n))

# Expected output:
The sum of n term is:  10000.0
# Brahmagupta Fibonacci Identity | Python 3 code to verify Brahmagupta Fibonacci identity ; represent the product as sum of 2 squares ; check identity criteria ; 1 ^ 2 + 2 ^ 2 ; 3 ^ 2 + 4 ^ 2 ; express product of sum of 2 squares as sum of ( sum of 2 squares )
def find_sum_of_two_squares(a, b):
    ab = a * b
    i = 0
    while (i * i <= ab):
        j = i
        while (i * i + j * j <= ab):
            if (i * i + j * j == ab):
                print(i, "^2 + ", j, "^2 = ", ab)
            j += 1
        i += 1


a = 1 * 1 + 2 * 2
b = 3 * 3 + 4 * 4
print("Representation of a * b as sum" " of 2 squares:")
find_sum_of_two_squares(a, b)

# Expected output:
Representation of a * b as sum of 2 squares:
2 ^2 +  11 ^2 =  125
5 ^2 +  10 ^2 =  125
# tetrahedral numbers | python3 program to find the nth tetrahedral number ; function to find tetrahedral number ; 
def tetrahedralNumber(n):
    return (n * (n + 1) * (n + 2)) / 6


def tetrahedralNumber(n):
    return (n * (n + 1) * (n + 2)) / 6


n = 5
print(tetrahedralNumber(n))

# Expected output:
35.0
# perfect power ( 1 , 4 , 8 , 9 , 16 , 25 , 27 , ... ) | python3 program to count number of numbers from 1 to n are of type x ^ y where x > 0 and y > 1 ; function that keeps all the odd power numbers upto n ; we need exclude perfect squares . ; sort the vector ; return sum of odd and even powers . ; 

import math


def powerNumbers(n):
    v = []
    for i in range(2, int(math .pow(n, 1.0 / 3.0)) + 1):
        j = i * i
        while (j * i <= n):
            j = j * i
            s = int(math .sqrt(j))
            if (s * s != j):
                v .append(j)
    v .sort()
    v = list(dict .fromkeys(v))
    return len(v) + int(math .sqrt(n))


if __name__ == '__main__':
    print(powerNumbers(50))

# Expected output:
10
# find n arithmetic means between a and b | prints n arithmetic means between a and b . ; calculate common difference ( d ) ; for finding n the arithmetic mean between a and b ; 
def printAMeans(A, B, N):
    d = (B - A) / (N + 1)
    for i in range(1, N + 1):
        print(int(A + i * d), end=" ")


A = 20
B = 32
N = 5
printAMeans(A, B, N)

# Expected output:
22 24 26 28 30
# sum of the series 1.2 . 3 + 2.3 . 4 + ... + n ( n + 1 ) ( n + 2 ) | function to calculate sum of series ; 
def sumofseries(n):
    return int(n * (n + 1) * (n + 2) * (n + 3) / 4)


print(sumofseries(3))

# Expected output:
90
# largest number in [ 2 , 3 , . . n ] which is co | python3 code to find largest number in [ 2 , 3 , . . n ] which is co - prime with numbers in [ 2 , 3 , . . m ] ; returns true if i is co - prime with numbers in set [ 2 , 3 , ... m ] ; running the loop till square root of n to reduce the time complexity from n ; find the minimum of square root of n and m to run the loop until the smaller one ; check from 2 to min ( m , sqrt ( n ) ) ; def to find the largest number less than n which is co - prime with all numbers from 2 to m ; iterating from n to m + 1 to find the number ; checking every number for the given conditions ; the first number which satisfy the conditions is the answer ; if there is no number which satisfy the conditions , then print number does not exist . ; 

import math


def isValid(i, m):
    sq_i = math .sqrt(i)
    sq = min(m, sq_i)
    for j in range(2, sq + 1):
        if (i % j == 0):
            return False
    return True


def findLargestNum(n, m):
    for i in range(n, m, -1):
        if (isValid(i, m)):
            print("{}".format(i))
            return
    print("NumberDoesn'tExists")


n = 16
m = 3
findLargestNum(n, m)

# Expected output:
13
# check whether a given matrix is orthogonal or not |  ; find transpose ; find product of a [ ] [ ] and its transpose ; since we are multiplying with transpose of itself . we use ; check if product is identity matrix ; 
def isOrthogonal(a, m, n):
    if (m != n):
        return False
    trans = [[0 for x in range(n)]for y in range(n)]
    for i in range(0, n):
        for j in range(0, n):
            trans[i][j] = a[j][i]
    prod = [[0 for x in range(n)]for y in range(n)]
    for i in range(0, n):
        for j in range(0, n):
            sum = 0
            for k in range(0, n):
                sum = sum + (a[i][k] * a[j][k])
            prod[i][j] = sum
    for i in range(0, n):
        for j in range(0, n):
            if (i != j and prod[i][j] != 0):
                return False
            if (i == j and prod[i][j] != 1):
                return False
    return True


a = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
if (isOrthogonal(a, 3, 3)):
    print("Yes")
else:
    print("No")

# Expected output:
Yes
# check if given number is perfect square | python program to find if x is a perfect square . ; find floating point value of square root of x . ; sqrt function returns floating value so we have to convert it into integer return boolean t / f ; 

import math


def isPerfectSquare(x):
    if (x >= 0):
        sr = math .sqrt(x)
        return ((sr * sr) == float(x))
    return false


x = 2502
if (isPerfectSquare(x)):
    print("Yes")
else:
    print("No")

# Expected output:
No
# Program to print GP ( Geometric Progression ) | function to print GP ; starting number ; Common ratio ; N th term to be find
def printGP(a, r, n):
    for i in range(0, n):
        curr_term = a * pow(r, i)
        print(curr_term, end=" ")


a = 2
r = 3
n = 5
printGP(a, r, n)

# Expected output:
2 6 18 54 162
# hcf of array of fractions ( or rational numbers ) | python 3 program to find hcf of array of ; find hcf of numerator series ; return hcf of numerator ; find lcm of denominator series ; ans contains lcm of arr [ 0 ] [ 1 ] , . . arr [ i ] [ 1 ] ; return lcm of denominator ; core function ; found hcf of numerator ; found lcm of denominator ; return result ; 

from math import gcd


def findHcf(arr, size):
    ans = arr[0][0]
    for i in range(1, size, 1):
        ans = gcd(ans, arr[i][0])
    return (ans)


def findLcm(arr, size):
    ans = arr[0][1]
    for i in range(1, size, 1):
        ans = int((((arr[i][1] * ans)) / (gcd(arr[i][1], ans))))
    return (ans)


def hcfOfFraction(arr, size):
    hcf_of_num = findHcf(arr, size)
    lcm_of_deno = findLcm(arr, size)
    result = [0 for i in range(2)]
    result[0] = hcf_of_num
    result[1] = lcm_of_deno
    i = int(result[0] / 2)
    while (i > 1):
        if ((result[1] % i == 0) and (result[0] % i == 0)):
            result[1] = int(result[1] / i)
            result[0] = (result[0] / i)
    return (result)


if __name__ == '__main__':
    size = 4
    arr = [0 for i in range(size)]
    for i in range(size):
        arr[i] = [0 for i in range(2)]
    arr[0][0] = 9
    arr[0][1] = 10
    arr[1][0] = 12
    arr[1][1] = 25
    arr[2][0] = 18
    arr[2][1] = 35
    arr[3][0] = 21
    arr[3][1] = 40
    result = hcfOfFraction(arr, size)
    print(result[0], ",", result[1])

# Expected output:
3 , 1400
# space efficient iterative method to fibonacci number | get second msb ; consectutively set all the bits ; returns the second msb ; multiply function ; function to calculate f [ ] [ ] raise to the power n ; base case ; take 2d array to store number 's ; run loop till msb > 0 ; to return fibonacci number ; 
def getMSB(n):
    n |= n >> 1
    n |= n >> 2
    n |= n >> 4
    n |= n >> 8
    n |= n >> 16
    return ((n + 1) >> 2)


def multiply(F, M):
    x = F[0][0] * M[0][0] + F[0][1] * M[1][0]
    y = F[0][0] * M[0][1] + F[0][1] * M[1][1]
    z = F[1][0] * M[0][0] + F[1][1] * M[1][0]
    w = F[1][0] * M[0][1] + F[1][1] * M[1][1]
    F[0][0] = x
    F[0][1] = y
    F[1][0] = z
    F[1][1] = w


def power(F, n):
    if (n == 0 or n == 1):
        return
    M = [[1, 1], [1, 0]]
    m = getMSB(n)
    while m:
        multiply(F, F)
        if (n & m):
            multiply(F, M)
        m = m >> 1


def fib(n):
    F = [[1, 1], [1, 0]]
    if (n == 0):
        return 0
    power(F, n - 1)
    return F[0][0]


n = 6
print(fib(n))

# Expected output:
8
# stern | python program to print brocot sequence ; loop to create sequence ; adding sum of considered element and it 's precedent ; adding next considered element ; printing sequence . . ; 

import math


def SternSequenceFunc(BrocotSequence, n):
    for i in range(1, n):
        considered_element = BrocotSequence[i]
        precedent = BrocotSequence[i - 1]
        BrocotSequence .append(considered_element + precedent)
        BrocotSequence .append(considered_element)
    for i in range(0, 15):
        print(BrocotSequence[i], end=" ")


n = 15
BrocotSequence = []
BrocotSequence .append(1)
BrocotSequence .append(1)
SternSequenceFunc(BrocotSequence, n)

# Expected output:
1 1 2 1 3 2 3 1 4 3 5 2 5 3 4
# counting numbers whose difference from reverse is a product of k | python 3 program to count the numbers within a given range in which when you subtract a number from its reverse , the difference is a product of k ; function to check if the number and its reverse have their absolute difference divisible by k ; reverse the number ; 
def isRevDiffDivisible(x, k):
    n = x
    m = 0
    while (x > 0):
        m = m * 10 + x % 10
        x = x // 10
    return (abs(n - m) % k == 0)


def countNumbers(l, r, k):
    count = 0
    for i in range(l, r + 1):
        if (isRevDiffDivisible(i, k)):
            count = count + 1
    return count


l = 20
r = 23
k = 6
print(countNumbers(l, r, k))

# Expected output:
2
# program to print non square numbers | python 3 program to print first n non - square numbers . ; function to check perfect square ; function to print all non square number ; variable which stores the count ; not perfect square ; 

import math


def isPerfectSquare(n):
    if (n < 0):
        return False
    root = round(math .sqrt(n))
    return (n == root * root)


def printnonsquare(n):
    count = 0
    i = 1
    while (count < n):
        if (isPerfectSquare(i) == False):
            print(i, end=" ")
            count = count + 1
        i = i + 1


n = 10
printnonsquare(n)

# Expected output:
2 3 5 6 7 8 10 11 12 13
# program to print non square numbers | python 3 program to print first n non - square numbers . ; returns n - th non - square number . ; loop to print non squares below n ; 

import math


def nonsquare(n):
    return n + (int)(0.5 + math .sqrt(n))


def printNonSquare(n):
    for i in range(1, n + 1):
        print(nonsquare(i), end=" ")


n = 10
printNonSquare(n)

# Expected output:
2 3 5 6 7 8 10 11 12 13
# ludic numbers | returns a list containing all ludic numbers smaller than or equal to n . ; ludics list contain all the ludic numbers ; here we have to start with index 1 and will remove nothing from the list ; here first item should be included in the list and the deletion is referred by this first item in the loop . ; remove_index variable is used to store the next index which we want to delete ; removing the next item ; remove_index is updated so that we get the next index for deletion ; 
def getLudic(n):
    ludics = []
    for i in range(1, n + 1):
        ludics .append(i)
    index = 1
    while (index != len(ludics)):
        first_ludic = ludics[index]
        remove_index = index + first_ludic
        while (remove_index < len(ludics)):
            ludics .remove(ludics[remove_index])
            remove_index = remove_index + first_ludic - 1
        index += 1
    return ludics


n = 25
print(getLudic(n))

# Expected output:
[1, 2, 3, 5, 7, 11, 13, 17, 23, 25]
# prime triplet | function to detect prime number using sieve method https : www . geeksforgeeks . org / sieve - of - eratosthenes / to detect prime number ; if prime [ p ] is not changed , then it is a prime ; update all multiples of p ; function to print prime triplets ; finding all primes from 1 to n ; triplets of form ( p , p + 2 , p + 6 ) ; triplets of form ( p , p + 4 , p + 6 ) ; 
def sieve(n, prime):
    p = 2
    while (p * p <= n):
        if (prime[p]):
            i = p * 2
            while (i <= n):
                prime[i] = False
                i = i + p
        p = p + 1


def printPrimeTriplets(n):
    prime = [True] * (n + 1)
    sieve(n, prime)
    print("The prime triplets from 1 to ", n, "are :")
    for i in range(2, n - 6 + 1):
        if (prime[i] and prime[i + 2] and prime[i + 6]):
            print(i, (i + 2), (i + 6))
        elif (prime[i] and prime[i + 4] and prime[i + 6]):
            print(i, (i + 4), (i + 6))


n = 25
printPrimeTriplets(n)

# Expected output:
The prime triplets from 1 to  25 are :
5 7 11
7 11 13
11 13 17
13 17 19
17 19 23
# program to compare two fractions | get max of the two fractions ; declare nume1 and nume2 for get the value of first numerator and second numerator ; compute ad - bc ; 
def maxFraction(first, sec):
    a = first[0]
    b = first[1]
    c = sec[0]
    d = sec[1]
    Y = a * d - b * c
    return first if Y else sec


first = (3, 2)
sec = (3, 4)
res = maxFraction(first, sec)
print(str(res[0]) + "/" + str(res[1]))

# Expected output:
3/2
# find the nearest odd and even perfect squares of odd and even array elements respectively | python3 program for the above approach ; function to find the nearest even and odd perfect squares for even and odd array elements ; traverse the array ; calculate square root of current array element ; if both are of same parity ; otherwise ; 

import math


def nearestPerfectSquare(arr, N):
    for i in range(N):
        sr = int(math .sqrt(arr[i]))
        if ((sr & 1) == (arr[i] & 1)):
            print(sr * sr, end=" ")
        else:
            sr += 1
            print(sr * sr, end=" ")


arr = [6, 3, 2, 15]
N = len(arr)
nearestPerfectSquare(arr, N)

# Expected output:
4 1 4 9
# program to check if n is a pentagonal number | python3 program to check pentagonal numbers . ; function to determine if n is pentagonal or not . ; substitute values of i in the formula . ; 

import math


def isPentagonal(N):
    i = 1
    while True:
        M = (3 * i * i - i) / 2
        i += 1
        if (M >= N):
            break
    return (M == N)


N = 12
if (isPentagonal(N)):
    print(N, end=' ')
    print("is pentagonal ")
else:
    print(N, end=' ')
    print("is not pentagonal")

# Expected output:
12 is pentagonal
# sum of fourth powers of the first n natural numbers | python3 program to find the sum of forth powers of first n natural numbers ; return the sum of forth power of first n natural numbers ; 

import math


def fourthPowerSum(n):
    sum = 0
    for i in range(1, n + 1):
        sum = sum + (i * i * i * i)
    return sum


n = 6
print(fourthPowerSum(n))

# Expected output:
2275
# sum of fourth powers of the first n natural numbers | python3 program to find the sum of forth powers of first n natural numbers ; return the sum of forth power of first n natural numbers ; 

import math


def fourthPowerSum(n):
    return ((6 * n * n * n * n * n) + (15 * n *
            n * n * n) + (10 * n * n * n) - n) / 30


n = 6
print(fourthPowerSum(n))

# Expected output:
2275.0
# find unit digit of x raised to power y | python3 code to find the unit digit of x raised to power y . ; find unit digit ; get last digit of x ; last cyclic modular value ; here we simply return the unit digit or the power of a number ; 

import math


def unitnumber(x, y):
    x = x % 10
    if y != 0:
        y = y % 4 + 4
    return (((int)(math .pow(x, y))) % 10)


x = 133
y = 5
print(unitnumber(x, y))

# Expected output:
3
# aliquot sum | function to calculate sum of all proper divisors ; 
def aliquotSum(n):
    sm = 0
    for i in range(1, n):
        if (n % i == 0):
            sm = sm + i
    return sm


n = 12
print(aliquotSum(n))

# Expected output:
16
# average of squares of natural numbers | function to get the average ; 
def AvgofSquareN(n):
    return ((n + 1) * (2 * n + 1)) / 6


n = 2
print(AvgofSquareN(n))

# Expected output:
2.5
# program to implement simpson 's 3/8 rule | given function to be integrated ; function to perform calculations ; calculates value till integral limit ; 
def func(x):
    return (float(1) / (1 + x * x))


def calculate(lower_limit, upper_limit, interval_limit):
    interval_size = (float(upper_limit - lower_limit) / interval_limit)
    sum = func(lower_limit) + func(upper_limit)
    for i in range(1, interval_limit):
        if (i % 3 == 0):
            sum = sum + 2 * func(lower_limit + i * interval_size)
        else:
            sum = sum + 3 * func(lower_limit + i * interval_size)
    return ((float(3 * interval_size) / 8) * sum)


interval_limit = 10
lower_limit = 1
upper_limit = 10
integral_res = calculate(lower_limit, upper_limit, interval_limit)
print(round(integral_res, 6))

# Expected output:
0.687927
# container with most water | python3 code for max water container ; calculating the max area ; 
def maxArea(A, Len):
    area = 0
    for i in range(Len):
        for j in range(i + 1, Len):
            area = max(area, min(A[j], A[i]) * (j - i))
    return area


a = [1, 5, 4, 3]
b = [3, 1, 2, 4, 5]
len1 = len(a)
print(maxArea(a, len1))
len2 = len(b)
print(maxArea(b, len2))

# Expected output:
6
12
# Program for focal length of a lens | Function to determine the focal length of a lens ; Variable to store the distance between the lens and the image ; Variable to store the distance between the lens and the object
def focal_length(image_distance, object_distance):
    return 1 / ((1 / image_distance) + (1 / object_distance))


image_distance = 2
object_distance = 50
result = focal_length(image_distance, object_distance)
print("Focal length of a lens is ", result, " units.")

# Expected output:
Focal length of a lens is  1.923076923076923  units.
# count numbers in range l | check if the number is divisible by the digits . ; function to calculate the number of numbers ; 
def check(n):
    m = n
    while (n != 0):
        r = n % 10
        if (r > 0):
            if ((m % r) != 0):
                return False
        n = n // 10
    return True


def count(l, r):
    ans = 0
    for i in range(l, r + 1):
        if (check(i)):
            ans = ans + 1
    return ans


l = 10
r = 20
print(count(l, r))

# Expected output:
5
# sum of the series 1 / ( 1 * 2 ) + 1 / ( 2 * 3 ) + 1 / ( 3 * 4 ) + 1 / ( 4 * 5 ) + . . . . . | function to find the sum of given series ; computing sum term by term ; 
def sumOfTheSeries(n):
    sum = 0
    for i in range(1, n + 1):
        sum += 1.0 / (i * (i + 1))
    return sum


if __name__ == '__main__':
    ans = sumOfTheSeries(10)
    print(round(ans, 6))

# Expected output:
0.909091
# sum of series ( n / 1 ) + ( n / 2 ) + ( n / 3 ) + ( n / 4 ) + ... ... . + ( n / n ) | python 3 program to find sum of given series ; function to find sum of series ; 

import math


def sum(n):
    root = (int)(math .sqrt(n))
    ans = 0
    for i in range(1, root + 1):
        ans = ans + n // i
    ans = 2 * ans - (root * root)
    return ans


n = 35
print(sum(n))

# Expected output:
131
# sum of the series 2 + ( 2 + 4 ) + ( 2 + 4 + 6 ) + ( 2 + 4 + 6 + 8 ) + â €¦ â €¦ + ( 2 + 4 + 6 + 8 + â €¦ . + 2 n ) | function to find the sum of the given series ; sum of 1 st n natural numbers ; sum of squares of 1 st n natural numbers ; required sum ; 
def sumOfTheSeries(n):
    sum_n = int((n * (n + 1) / 2))
    sum_sq_n = int((n * (n + 1) / 2) * (2 * n + 1) / 3)
    return (sum_n + sum_sq_n)


n = 5
ans = sumOfTheSeries(n)
print(ans)

# Expected output:
70
# sum of squares of binomial coefficients | return the sum of square of binomial coefficient ; calculate value of binomial coefficient in bottom up manner ; base cases ; calculate value using previously stored values ; finding the sum of square of binomial coefficient . ; 
def sumofsquare(n):
    C = [[0 for i in range(n + 1)]for j in range(n + 1)]
    for i in range(0, n + 1):
        for j in range(0, min(i, n) + 1):
            if (j == 0 or j == i):
                C[i][j] = 1
            else:
                C[i][j] = (C[i - 1][j - 1] + C[i - 1][j])
    sum = 0
    for i in range(0, n + 1):
        sum = sum + (C[n][i] * C[n][i])
    return sum


n = 4
print(sumofsquare(n), end="")

# Expected output:
70
# program to find sum of series 1 + 2 + 2 + 3 + 3 + 3 + . . . + n | python3 program to find sum of series 1 + 2 + 2 + 3 + . . . + n ; function that find sum of series . ; 

import math


def sumOfSeries(n):
    sum = 0
    for i in range(1, n + 1):
        sum = sum + i * i
    return sum


n = 10
print(sumOfSeries(n))

# Expected output:
385