## Thursday, September 17, 2020

solution Exercise 757: python algorithm to find the remainder the Euclidean division of the sum of the first n integers

#### Exercise 757

Given a non-zero natural integer n, write a python algorithm as function which determines the remainder in the Euclidean division of the sum of the first n integers by n.

#### Solution

``````# create a function calculating the sum of the first n numbers 1 + 2 + 3 + ... + n
def sumNumbers(n):
# initializing the sum of first n numbers
sumNb = 0
for i in range(0 , n + 1):
sumNb = sumNb + i
return sumNb
def divEuclid(n):
return sumNumbers(n)%n

# Testing algorithm
print("The remainder in the Euclidean division of the sum of the first 4 integers by 4 is : ", divEuclid(4))``````

Younes Derfoufi
my-courses.net

## Python Exercises With Solutions

1. Python Arithmetic Exercises
2. Equations & System Of Equations
3. Polynomials and Functions
4. Python Arithmetic Exercises
5. Numpy, Matplolib, Sympy , Scipy - Exercises
6. Python Arithmetic Exercises

Younes Derfoufi

## Sample Text 