1 Questions
1. Candy Sharing: Alice and Bob have a bag of candies. They want to share the candies equally between
them. Write an algorithm to determine if it is possible to divide the candies evenly, assuming they can
only split the candies into whole numbers. Print “YES” if possible, and “NO” otherwise.
2. Leap Year: Write an algorithm to determine if a given year is a leap year. Print “YES” if it is a leap
year, and “NO” otherwise. (Hint: A leap year is divisible by 4 but not divisible by 100, unless it is also
divisible by 400.)
3. Triangle Inequality: Given the lengths of three sides of a triangle, write an algorithm to determine if a
triangle can be formed using those side lengths. Print “YES” if a triangle can be formed, and “NO”
otherwise. (Hint: In a triangle, the sum of the lengths of any two sides must be greater than the length
of the third side.)
4. Factorial: Write an algorithm to calculate the factorial of a given number. The factorial of a number n is
the product of all positive integers from 1 to n. Print the factorial as the output.
5. Counting in Multiples: Write an algorithm to count from 1 to 20, but only print the numbers that are
multiples of 3.