Category «While loop»

The sum of the sequence

The sum of the sequence. Determine the sum of all elements in a sequence of non-negative integers, where the sequence ends with the number 0. Do not include the 0 in the sum. Test Case Input (Sequence) Expected Output 1 1 2 3 0 6 2 4 0 1 2 4 3 7 3 5 …

The length of the sequence

The length of the sequence. Given a sequence of non-negative integers where each number is written on a separate line, determine the length of the sequence. The sequence ends when an integer equal to 0 is encountered. Print the length of the sequence, excluding the integer 0. Numbers following the number 0 should be omitted. …

Morning jog

Morning jog. As a future athlete, you are training for an upcoming event. On the first day, you run x miles, and by the event, you must be able to run y miles. Calculate the number of days required to reach the required distance for the event if you increase your distance by 10% each day from …

The power of two

The power of two. For a given integer N, find the greatest integer x such that 2x is less than or equal to N. Print the exponent value and the result of the expression 2x. Do not use the ** operation. Test Case Input (N) Expected Output 1 10 3 8 2 20 4 16 3 …

Least divisor

Least divisor. Given an integer not less than 2, print its smallest integer divisor greater than 1. Test Case Input (Integer) Expected Output 1 10 2 2 15 3 3 17 17  

List of squares

List of squares. For a given integer N, print all the squares of integer numbers where the square is less than or equal to N, in ascending order. Test Case Input (N) Expected Output 1 10 1 4 9 2 20 1 4 9 16 3 30 1 4 9 16 25