Identify Prime Numbers
Single File Programming Question
Problem Statement:
Ranjith wants to identify all prime numbers from a given list of integers. Write a program that reads n integers, stores them in a file named numbers.txt, then reads the file to find prime numbers and saves them in primes_result.txt.
If no prime numbers are present in the list, write "No primes found" to the output file.
Input:
format :The first line contains an integer n, the number of elements in the list.
The second line contains n space-separated integers.
Output:
format :Print the prime numbers to the console and write them in primes_result.txt.
If there are no prime numbers, print and write "No primes found".
Refer to the sample output for formatting specifications.
Code constraints : 1 ≤ n ≤ 15
1 ≤ numbers ≤ 100
Sample test cases :
Input 1:
5
2 4 7 9 11
Output 1 :
2 7 11
Input 2 :
3
4 6 8
Output 2 :
No primes found
Note :
The program will be evaluated only after the “Submit Code” is clicked.
Extra spaces and new line characters in the program output will result in the failure of the test case.
Marks : 10
Negative Marks : 0