Python Programming: An Introduction to Computer Science
Python Programming: An Introduction to Computer Science
3rd Edition
ISBN: 9781590282779
Author: John Zelle
Publisher: Franklin Beedle & Associates
Question
Book Icon
Chapter 8, Problem 6PE
Program Plan Intro

Displaying the prime numbers

Program Plan:

  • Import the header file.
  • Declare the “isPrime” function.
    • Set the values
    • Check “i” is less than or equal to “x”.
      • Check “n % i” is equal to 0.
        • Return the value.
      • Otherwise, calculate the “i” value.
        • Display the prime numbers.
    • Return the result.
  • Get the input from the user.
  • Iterate the “i” till reaches the input value
    • Call the “isPrime” function with the input value.

Blurred answer
Students have asked these similar questions
Print the multiplication of 5 without using * operator. You have to write a program for that.
Write a program to find the sum for the following series: اكتب برنامج لايجاد المتسلسله التاليه : (1*10) + (3*10)+ (5*10)... (n*10).
# Exercise 1. Implement the algorithm covered in lectures that determines if an integer n is prime. Your function should return True, if n is prime, and False otherwise. Your algorithm has to be effective for n ~ 1,000,000,000,000.def isPrime(n):
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education