Assignment 2
Deadline - Tuesday, Feb 17 Wednesday, Feb 25
The Question
Before starting this assignment, read the question number 8 on page 115 of your textbook atleast once. If you do not understand the question, ask
me. In this assignment we are dealing with generating and testing prime numbers. Prime numbers are very important in information security because they are impossible to predict and to break it in
to smaller parts. Part 1 wants you to find the solution of f(i) using the equation given to you which is f(i) = i2 + i + 41. Now they do mention that this equation generated prime
numbers for any i upto 6. In the Second part you have to show us that for any i greater than 6, f(i) can still generate prime numbers.
What do I need from you
- Source file called assignment2.cpp which has your source code. You do not need to submit any other file(s).
Please check the important guidelines before submitting your project to me.
The assignment is due by Wednesday, Feb 25.
Additional help for the assignment
- For both the parts of the assignment, they have to implemented in a single file but as seperate functions. This means, you will write two functions, They are
- f(i) - This function takes in the value i from the user and returns the function result of f(i). Suggested data types should be int for both input and output.
- test_prime(j) - This function takes j which is equal to f(i) and returns tru of false depending if f(i) is prime or not. Suggested input will be of type int but the output will be of type
bool (short for boolean, remember boolean is a special data type which has only two values true and false). The algorithm for testing wether a number is prime would look like
function test_prime(int j); output bool
begin
for all numbers between 2 and j, check if division of j with that number returns any remainder or not.
If there is even a single case where the above step has 0 remainder j is not a prime(return false). On the other hand if none of the remainders are 0 then j is prime(return true)
end
- If you have any doubts, come and meet me in my office hours. Please use them as they are meant for you.
If these timings are not convinient, email me with your best timings.
Back