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

 

commonFactor


boolean commonFactor(num1, num2, divisor): Given 2 numbers and a divisor, determine if the divisor is a factor of both numbers. A divisor is a factor of a number if it divides that number evenly (the remainder will be zero). If the divisor is 0, the division is impossible, so return false. You can use the % "mod" operator to make this determination. RUBRIC: It is not enough to just solve the problem. Make sure you use PROPER INDENTATION. You MUST use CURLY BRACKETS for all loops and if/else statements. Also, the more EFFICIENT your solution, the higher your grade. If you have extraneous (superfluous / unnecessary) code, deductions will be taken.


commonFactor(10, 20, 5) → true
commonFactor(10, 20, 4) → false
commonFactor(10, 20, 10) → true

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

public boolean commonFactor(int num1, int num2, int divisor) { }

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: 5

Copyright Nick Parlante 2017 - privacy