In the file sumSqr.c write a function int sumSqr ( int n ) that accepts one integer parameter and returns the sum of the squares of the numbers from 1 to n: 1*1 + 2*2 + 3*3 + ... +n*n. For example, if n = 1, the function returns 1, if n = 2, the function returns 5, if n = 3, the function returns 14.
Write a C program that reads a sequence of positive numbers, the first non-positive integer terminates the input. The program prints for each input number the corresponded sum of squares, using function sumSqr.
The greatest common divisor (GCD)of two integers is the
largest number that divides each of the two numbers.
For example, GCD (12, 8) = 4, GCD (12, 13) = 1. GCD could be found using
the following Euclidean Algorithm:
gcd (a, b) = b,
if a % b is 0
gcd ( a, b )= gcd( b, a % b), if a % b is not 0
For example, if the input is 2 3 4 6 your program first, will find the sum which is: 24/18. After that, the program will find gcd of 24 and 18 which is 6 and simlify the fraction by dividing numerator and denominator by gcd. The result will be 4/3. Since this is improper fraction (4 >3) the program will print the result in the following way 1 1/3 (finding the integer part and fractional part).