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

 

gaurav.gupta@mq.edu.au loops > isPrime
prev  |  next  |  chance

A number is called prime if it is more than 1, and is divisible only by 1 and itself. Define a function that when passed an integer, returns true if it is prime, false otherwise. If you are not sure where to begin, just search on wikipedia (yes, wikipedia is awesome!) for "prime numbers".


isPrime(77) → false
isPrime(73) → true
isPrime(103) → true

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

boolean isPrime(int n) { }

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: 3 Post-solution available

Copyright Nick Parlante 2017 - privacy