You are on page 1of 1

Lucky Winner

Problem Statement:
You have to design a program to find out the lucky winner for a Lottery considering the following
conditions based on a coupon containing N numbers on it.
1. First you have to check whether the median (integer) of all numbers from the coupon is a
prime or not. If prime then proceed to next step (2) otherwise go to Looser Step.
2. If the prime number is a palindrome then proceed to next step (3) otherwise go to Looser
Step (7).
3. Find out the sum of the digit of the palindrome number and check whether the resulting
number is also a prime or not. IF the number is a prime then go to Winner Step (6) otherwise
go to next step (4).
4. Find the Maximum factor of the resulting number and check whether it is a prime or not. If
the number is a prime then go to Winner Step (6) otherwise go to next step (5).
5. Repeat the previous step (4) until a prime factor will have been found. If a prime factor is
found then go to Winner Step (6) otherwise go to Looser Step (7).
6. Winner Step: Declare the contestant Winner.
7. Looser Step: Declare the contestant Looser.
Input:
Input begins with an integer N (2 ≤ N ≤ 100), the number of N positive integer number. Next line
contains the N numbers.
Output:
You should print one line showing the message “WINNER” or “LOOSER”.
Sample Input:
5
381 382 383 384 385
6
10 15 17 18 20 25
Sample Output:
WINNER
LOOSER

You might also like