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

 

frew@mclean.com > smallestFactor
prev  |  next  |  chance

Write a method named smallestFactor that accepts a positive number and returns the smallest factor of the number other than 1. If the number is prime, the method returns 1.


smallestFactor(457) → 1
smallestFactor(1) → 1
smallestFactor(34555) → 5

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

public int smallestFactor(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: 200

Copyright Nick Parlante 2017 - privacy