You are on page 1of 1

CSC206-Programming I

2020-2021 Fall Semester


Assignment II

I. A number is called Armstrong number if the sum of the cube of its digits is
equal to the number itself. Example:
153 = 13 + 53 + 33 then 153 is an Armstrong number.
201 ≠ 23 + 03 + 13 then 201 is not an Armstrong number.
Write a function that takes an integer n then return true if n is an
Armstrong number and false else

II. Write a function that takes an integer n then prints on the screen a
triangle as follows:
If n= 4
The output should be:
1
23
456
7 8 9 10

III. Write a function that takes two integers x and y then return the following
sum:
1 + x + x2/2! + x3/3! + … + xy/y!

Example if x=3 and y= 4 then the program will calculate 1 + 3 + 32/2! +

33/3! + x4/4! And the function will return 14.125

IV. write a program that test all the previous functions you did in I,II, and III

You might also like