You are on page 1of 2

Problem Number 1

An integer greater than one is called a prime number if its only positive divisors (factors) are one and itself. The first six primes are 2, 3, 5, 7, 11 and 13. Write a program to output all prime numbers less than a number, specified by the user. Sample dialog is as follows: PRIMES Input number: 25 The prime numbers less than 25 are: 2 3 5 7 11 13 17 19 23 Do you want to try again (Y/N)? h Invalid answer! Press Y is yes, N if No. Do you want to try again (Y/N)? N Thank you for using this program.

Problem Number 2
Write a program that will output the prime factors of a number given by the user. The program should determine whether or not a number n is a prime or not. Sample dialog is as follows: PRIME FACTORS Input Number: 924 924 can be factored as 2 * 2 * 3 * 7 * 11

Problem Number 3
The famous Goldbachs conjecture can be stated as: Every even integer greater than 6 is the sum of two odd primes. Write a program that will prove that the conjecture is true by having the user input both the starting even number and the end number and the program should output similar to the dialog below: GOLDBACHS CONJECTURE Input begin number: 700 end number: 1100 The even numbers expressed as a sum of two odd primes according to Goldbachs conjecture are: 700 = 17 + 683 702 = 11 + 691 : 1098 = 5 + 1093 1100 = 3 + 1097 Do you want to try again (Y/N)? n Thank you for using this program.

Problem Number 4
A leap year is a year in which an extra day in added to the calendar in order to synchronize it with the seasons. Since the tropical year is 365.242190 days long, a leap year must be added roughly once every four years. In a leap year, the extra day (known as a leap day) is added at the end of February, giving it 29 instead of the usual 28 days. In the Gregorian calendar currently in use worldwide, there is a leap year every year divisible by four except for years which are both divisible by 100 and not divisible by 400. Therefore, the year 2000 will be a leap year, but the years 1700, 1800, and 1900 were not. Write a program to output leap years in a certain year range: LEAP YEARS Input begin year: 2000 end year: 2050

Leap years from 2000 to 2050 are: 2000, 2004, 2008, 2012, 2016, 2020, 2024, 2028, 2032, 2036, 2040, 2044, and 2048 Do you want to try again (Y/N)? S Invalid answer! Press Y is yes, N if No. Do you want to try again (Y/N)? n Thank you for using this program!

Problem Number 5
A perfect number is a number whose proper divisors sum to the number itself. E.g. the number 6 has proper divisors 1, 2 and 3 and 1 + 2 + 3 = 6, 28 has divisors 1, 2, 4, 7, and 14 and 1 + 2 + 4 + 7 + 14 = 28. Write a program to output perfect numbers less than a user specified number. PERFECT NUMBERS Input number: 75 The perfect numbers less than 7 are: 6 28 Do you want to try again (Y/N)? N Thank you for using this program.

You might also like