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

 

orion.a.smith@gmail.com apcsa-loops > apcsaLoopsConcatFactorsOfB
prev  |  next  |  chance

Given two numbers a and b, build a String that contains every number which is a factor of b, from a to b, inclusive. Preconditions: a < b for all inputs, a > 0.


A factor, also called a divisor, is a number that divides into another without leaving a remainder.  The divisors of 10 are 1,2,5 and 10 (every number divides itself without a remainder).

For example if a is 3 and b is 10, the following decisions would be made.
Skip 3, 10 % 3 != 0.
Skip 4, because 10 % 4 != 0.
Include 5, because 5 is a factor of 10 (10 % 5 == 0).
Skip 6, because 10 % 4 != 0.
Skip 7, because 10 % 7 != 0.
Skip 8, because 10 % 8 != 0.
Skip 9, because 10 % 9 != 0.
Include 10, because 10 is a factor of 10 (10 % 10 == 0).
Thus, the overall result would be "510" for a == 3 and b == 10.

apcsaLoopsConcatFactorsOfB(3, 10) → "510"
apcsaLoopsConcatFactorsOfB(3, 12) → "34612"
apcsaLoopsConcatFactorsOfB(3, 4) → "4"

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

public String apcsaLoopsConcatFactorsOfB(int a, int b) { }

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

Copyright Nick Parlante 2017 - privacy