3: Loops

3.1 Largest Number

Coding Exercise: Largest Number
Given n numbers. Output the largest number.
You may enter input for the program in the box below.

3.2 Factorial

Coding Exercise: Factorial
The number n factorial is the defined as the product of numbers from 1 to n. For example, 5! = 1*2*3*4*5. Given number n, calculate and output its factorial.
You may enter input for the program in the box below.

3.3 Fibonacci Numbers

Coding Exercise: Fibonacci Numbers
Fibonacci numbers are defined in the following way:
F1 = 1; F2 = 1; Fn = Fn-1 + Fn-2
Given n, write a program to find and output Fn.
You may enter input for the program in the box below.

3.4 Lucky ticket

Coding Exercise: Lucky ticket
Lottery tickets are numbered from 0000 to 9999. The ticket is ‘lucky’ if the sum of its first two digits is equal to the sum of its last two digits.
Write a program to calculate the total number of lucky tickets.

3.5 Lucky ticket with even digits

Coding Exercise: Lucky ticket with even digits
Lucky lottery ticket is defined in the previous task. Write a program to output the total number of lucky tickets that have even digits only.

3.6 Two Jars with Nuts

Coding Exercise: Two Jars with Nuts
There are two jars. The first jar is full of nuts, the second jar is empty. The following algorithm is used form moving the nuts from the first jar to the second:
1) If the number of the nuts in the first jar is even, half of the nuts is moved from the first to the second jar
2) If the number of the nuts in the first jar is odd, one nuts is moved from the first to the second jar
Given the number of nuts in the first jar. Write a program to simulate this algorithm and output the total number of moves required to move all the nuts from the first to the second jar.
You may enter input for the program in the box below.

3.7 Odd and Even Digits

Coding Exercise: Odd and Even Digits
Given a natural number n. Output the number of its odd and even digits.
You may enter input for the program in the box below.

3.8 What's the sum? (1)

Coding Exercise: What's the sum? (1)
Given two natural numbers n and k. Write a program to calculate the following sum:
1*k+2*k+3*k+…+n*k
Use a loop to solve this problem.
You may enter input for the program in the box below.

3.9 What's the sum? (2)

Coding Exercise: What's the sum? (2)
Given a natural number n. Write a program to calculate the following sum:
1*2+2*3*4+…+n*(n+1)*(n+2)*…*2n
You may enter input for the program in the box below.

3.10 Palindromes

Coding Exercise: Palindromes
Numbers are palindromes if they read the same backward and forward. For example, 12521 is a palindrome.
Given natural numbers m and n. Write a program to calculate the number of palindromes in the interval [m; n].
You may enter input for the program in the box below.

3.11 Number with most divisors

Coding Exercise: Number with most divisors
Given two natural numbers m and n. Write a program to find the smallest number from the interval [m; n] that has most divisors.
You may enter input for the program in the box below.

3.12 Grid

Coding Exercise: Grid
Take as input two numbers and a symbol. Output a grid made up of entirely of the chosen symbol, with the number of rows matching the first number input and the number of columns matching the second number input. (Worked example 11.09, p. 143)
For this task you will have to print in the same line. If you want NO new line AFTER printing something,
use print(rez, end='') instead of print(rez).
You may enter input for the program in the box below.