The number of zeros

The number of zeros. Given a series of N numbers where the first number in the input specifies N, followed by N integers, count how many of these integers are zero and print the count. Note that you need to count the number of integers that are equal to zero, not the number of zero …

Factorial

Factorial. In mathematics, the factorial of an integer n, denoted by n!, is the product of all positive integers from 1 to n: n! = 1 × 2 × … × n For a given integer n, calculate the value of n! without using the math module. Test Case Input (n) Expected Output 1 3 …

Sum of cubes

Sum of cubes. Given an integer N, calculate the sum of cubes of all integers from 1 to N: 13 + 23 + … + N3 Test Case Input (N) Expected Output 1 3 36 2 4 100 3 5 225  

Product of N numbers

Product of N numbers. Given an integer N followed by N integers, read these integers and print their product. The first line of input contains a positive integer N, which indicates how many integers will follow. Each of the next N lines contains one integer. Calculate and print the product of these N integers. Test …

Sum of N numbers

Sum of N numbers. Given an integer N followed by N integers, read these integers and print their sum. The first line of input contains the integer N, which indicates how many integers will follow. Each of the next N lines contains one integer. Calculate and print the sum of these N integers. Test Case …

Sum of ten numbers

Sum of ten numbers. Given 10 numbers as input, read them and print their sum using as few variables as possible. Test Case Input (10 numbers) Expected Output 1 1 2 3 4 5 6 7 8 9 10 55 2 10 20 30 40 50 60 70 80 90 100 550 3 5 5 …

Series – 2

Series – 2. Given two integers A and B, print all numbers from A to B inclusively in ascending order if A is less than B, otherwise print them in descending order. Test Case Input (A, B) Expected Output 1 3 7 3 4 5 6 7 2 5 1 5 4 3 2 1 …

Series – 1

Series – 1. Given two integers A and B (where A is less than or equal to B), print all numbers from A to B, inclusive. Test Case Input (A, B) Expected Output 1 1 5 1 2 3 4 5 2 -3 2 -3 -2 -1 0 1 2 3 7 7 7