subject

Write a program to test for primality of any number n (that is, to test if n is a prime number). start by writing an algorithm (a set of precise mathematical steps that can be written into a program) to test for primality. for full credit, run the program and use it to test for primality on several numbers. see what the largest number your program can handle is before you find it too slow to yield a result in a reasonable time (if it takes longer than 10 minutes to execute, you are done). use your own imagination. remember that if the number n is even, it cannot be a prime number. you can write your program to simply try if it is a multiple of any numbers smaller than n. also you can design your program to store all prime numbers less than n that your program has found, then take advantage of the fact that a number only needs to be tested to see if it is a multiple of those prime numbers smaller than n/2. if it is not, then it must be a prime number itself.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 09:40
It is vital to research each of the services you plan to disable before implementing any change, especially on critical machines such as the: a. servers in the test environment. b. domain controller and other infrastructure servers. c. desktops that have previously been attacked. d. desktops used by upper-level management.
Answers: 2
question
Computers and Technology, 22.06.2019 12:00
Which of the following “invisible” marks represents an inserted tab?
Answers: 1
question
Computers and Technology, 23.06.2019 18:40
Johnson enterprises uses a computer to handle its sales invoices. lately, business has been so good that it takes an extra 3 hours per night, plus every third saturday, to keep up with the volume of sales invoices. management is considering updating its computer with a faster model that would eliminate all of the overtime processing.
Answers: 2
question
Computers and Technology, 24.06.2019 14:40
Create a function (prob3_6) that will do the following: input a positive scalar integer x. if x is odd, multiply it by 3 and add 1. if the given x is even, divide it by 2. repeat this rule on the new value until you get 1, if ever. your program will output how many operations it had to perform to get to 1 and the largest number along the way. for example, start with the number 3: because 3 is odd, we multiply by 3 and add 1 giving us 10. 10 is even so we divide it by 2, giving us 5. 5 is odd so we multiply by 3 and add one, giving us 16. we divide 16 (even) by two giving 8. we divide 8 (even) by two giving 4. we divide 4 (even) by two giving 2. we divide 2 (even) by 2 to give us 1. once we have one, we stop. this example took seven operations to get to one. the largest number we had along the way was 16. every value of n that anyone has ever checked eventually leads to 1, but it is an open mathematical problem (known as the collatz conjectureopens in new tab) whether every value of n eventually leads to 1. your program should include a while loop and an if-statement.
Answers: 3
You know the right answer?
Write a program to test for primality of any number n (that is, to test if n is a prime number). sta...
Questions
question
Mathematics, 15.05.2021 01:00
question
Mathematics, 15.05.2021 01:00
Questions on the website: 13722362