Reference no: EM132103237
A prime number is an integer that is evenly divisible only by 1 and itself. For example, the only integers that divide 7 evenly are 1 and 7, thus 7 is a prime number.
On the other hand, a number that is not prime is said to be composite. An integer n is composite if there exist integers a and b such that n = ab, with 1 < a < n, and 1 < b < n. For example, the number 24 is composite since it can be factored in the following ways: 24 = 2 X 12, 24 = 3 X 8, and 24 = 4 X 6, with other factorizations possible, including 24 = 1 X 24 (but not only this way).
Write a method named isPrime, which takes an integer as an argument and returns true if the argument is prime or false otherwise. Write a driver program with a main method that calls the isPrime method to demonstrate that it works.
Finally, modify your program so that it makes use of the isPrime method to store a list of all the prime numbers from 1 to 100 in a text file.
The list should look like the following:
2
3
5
.
.
.
97
What tactics she can use to get a higher ranking
: She also wants to know if she should start a paid ad campaign on Google too. What advice would you give her?
|
Calculate the final purchase price after discount
: At the President's Day sale, a customer can bring in a coupon for a 10%, 20% or 30% discount off of total purchases.
|
Determine the value of the function pn for different value
: Write a program to determine the value of the function P(n) for different values of n. The first few prime sums are 2, 5, 10, 17, 28, 41, 58 and 77.
|
What advice would you give her
: Pretend that you are a SEO consultant hired by a new home baker who is planning on selling her products thorough the internet.
|
Write a driver program with a main method
: Write a method named isPrime, which takes an integer as an argument and returns true if the argument is prime or false otherwise.
|
Write your solution using dynamically allocated arrays
: Even though this assignment can be coded with statically allocated arrays, please write your solution using dynamically allocated arrays.
|
How can you print three rows of values on an lcd
: How can you print three rows of values on an LCD using mbed at the same time for example time, date and year.
|
Test your methods within a class and check
: Test your methods within a class and check that they work properly. Use the method prime(int n) in the implementation of the other 2 methods.
|
Create an array of bool values that are true for all prime
: Create an array of bool values that are true for all prime numbers but are false otherwise. Initially set all of the array entries to true.
|