id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

jebbert@volusia.k12.fl.us > dec18_2017_HL_isPrime
prev  |  next  |  chance

Write a method that accepts an integer as an input parameter. As a pre-condition you may assume that this input parameter will be greater than or equal to 2. Return 'true' if that number is a prime number. Return 'false' if it is NOT a prime number. Recall that prime numbers only have themselves and 1 as whole-number factors. For example, 14 is NOT prime because 7*2=14. But 13 IS prime because 1*13 or 13*1 are the only ways to factor it into whole numbers. Your program must be able to handle ANY input parameter between 2 and 150000. Note: You may get occasional time-outs due to the server running differing numbers of processes. Try running again. If you get "all green" you have solved the problem.


dec18_2017_HL_isPrime(65537) → true
dec18_2017_HL_isPrime(104729) → true
dec18_2017_HL_isPrime(102845) → false

...Save, Compile, Run (ctrl-enter)

public boolean dec18_2017_HL_isPrime(int num) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 290

Copyright Nick Parlante 2017 - privacy