subject

I am writing a code that requires me to identify a positive integer as a prime (or not). I have looked at references on how to find it but it does not work for what I am trying to do. Below is the set of instructions. I have written the first half of the code and verified that it works. I am stuck on how to write the logic that identifies the prime based on the instructions.
Write a program that prompts the user to input a positive integer. It should then output a message indicating whether the number is a prime number.
Your program should use a loop to validate the positive integer and accept the input only when the user inputs a positive number.
Your code should be an efficient algorithm using the following note.
(Note: An even number is prime if it is 2. An odd integer is prime if it is not divisible by any odd integer less than or equal to the square root of the number.)
For the square root, import the math library (import math) and use math. sqrt() function)

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 00:30, lesok0818
Advantages and disadvantages of binary system
Answers: 1
image
Computers and Technology, 23.06.2019 12:00, clevelandjaniya1
Which of these is a benefit of using objects in a powerpoint presentation? a. collaborators can create the external files while you create and edit the slide show. b. you can easily change the theme and design of the presentation. c. you can have older data in the source file while having up-to-date data in the presentation. d. collaborators can easily share the presentation.
Answers: 2
image
Computers and Technology, 23.06.2019 15:30, jasssp
Write a program in plp assembly that counts up by one starting from zero (or one) inside a loop and writes this value to the leds every time the value is increased. the memory address of the leds is 0xf0200000. the table below shows the meaning and an example usage of the instructions covered in the video, plp instructions for project 1. instruction example usage meaning load immediate li $t0, 8 register $t0 is set to the value, 8. store word sw $t2, 0($t1) the value in register $t1 is used as the memory address. the value in register $t2 is copied into this memory address. add addiu $t4, $t3, 29 register $t4 is assigned the sum of 29 and the value in register $t3. jump j your_label_name the program jumps to the line following the label, "your_label_name: ". label your label name: defines a label called "your_label_name: " that can be jumped to
Answers: 2
image
Computers and Technology, 23.06.2019 17:00, osirisarellane3792
*! 20 points! *jeff wants to create a website with interactive and dynamic content. which programming language will he use? a. dhtml b. html c. css d. javascript
Answers: 1
You know the right answer?
I am writing a code that requires me to identify a positive integer as a prime (or not). I have look...

Questions in other subjects: