Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The whole purpose of my program is that a user inputs a number and according to that number it then prints out all the prime

image text in transcribed

The whole purpose of my program is that a user inputs a number and according to that number it then prints out all the prime numbers leading up to the input. So for example, if the input is 20 it'll print out 2, 3, 5, .... all the way to 19. (Since 20 is not prime). This method can print the prime numbers but for some reason it is printing out 1 (1 is not prime). How can I get it to not print 1?

public boolean isPrime (int number) int prime; for (prime = 2; prime

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And Relational Theory Normal Forms And All That Jazz

Authors: Chris Date

1st Edition

1449328016, 978-1449328016

More Books

Students also viewed these Databases questions