Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

CAN ANYBODY HELP ME WITH THIS DISCRETE MATH LAB !! ASAP, THANKS IN ADVANCE Write

ID: 3830267 • Letter: C

Question

CAN ANYBODY HELP ME WITH THIS DISCRETE MATH LAB !! ASAP, THANKS IN ADVANCE

Write a method that takes as input a natural number n and determines if n is a prime number. Consider the sequence of prime numbers 2, 3, 5, 7, 11, 13, 17, .... Let p_i denote the i-th number in the sequence i.e., p_1 = 2, p_2 = 3, p_3 = 5, p_4 = 7, p_5 = 11 .... For i > 0, let N_i = p_1 * p_2 * ... * p_i + 1. Professor Paul Erdos claims that for all i > 0, N_i is a prime number. Prove that Professor Erdos is wrong. Write a computer program that produces the smallest counter-example for Professor Erdos' claim.

Explanation / Answer

a)

bool isPrime(int n){

   // base case
   if(n <= 1)
       return false;

   // interating from i=2 to n/2
   for(int i=2; i<=n/2; i++){
       // if n is divisible then n is not prime
       if(n%i == 0)
           return false;
   }

   return true; // n is prime number
}

b)

p1 = 2, p2 = 3

N2 = p1*p2 = 2*3 = 6

6 is not a prime number

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote