Question: the second picture is the code that needs to be edited 1 The script EGA118_M2_01.m attempts to calculate the sum of the first n prime

1 The script EGA118_M2_01.m attempts to calculate the sum of the first n prime numbers. Note that 2 is the first prime and the sum of the first seven primes is 58. There are a small number of minor errors in the script that you need to correct. No lines need to be added to the script to make it run correctly. You only need to adjust some of the exiting lines. Having corrected the existing script you should change the script so that the user is asked to provide a value for n. (10 marks clear % This scripts attempts to find the sum of the first n primes i=1; prime_count=0; sum = 0; n=7; while prime_count can if -isprime(1) % isprime returns TRUE if i is a prime prime_count = prime_count + 1; sun = sum + 1; end i = i + 1; end fprintf('The sum of the first %d primes is %d ', n, sum)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
