Producing uniform lists in Scala
Here are few more ways to produce your uniform lists:

def f0(a: Int, b: Int) = {
  val c = a % b
  val d = a / b
  val n = if (c == 0) d else d + 1
  (1 to n).toList map (i =&gt; if (i * b &lt;= a) b else c)
}

def f1(a: Int, b: Int) = {
  val c  = a % b
  val d  = a / b
  val xs = List.fill(d)(b)
  if (c == 0) xs
  else        xs ::: c :: Nil
}

def f2(a: Int, b: Int) = {
  val r = a % b
  val n = a / b
  if (r == 0) List.fill(n)(b) 
  else        List.tabulate(n + 1)(i =&gt; if ((i + 1) * b &lt;= a) b else r)
}



f0 is a different/interesting way to derive your lists but to my mind is harder to parse that f1
f1 is very similar to what you have already but instead of redundantly concatenating Nil when rest == 0 we simply return the list as is
f2 is quite ugly but utilizes tabulate so I thought I'd include it


You'll notice that in each of the four functions considered so far we calculate rest = sum % nums and then branch based on the result of this calculation. While I can think of other ways to derive a value for rest they aren't as intuitive as the % operator and in the end I think we would still have a conditional statement which decided the final element of the list. 

Other than adopting the small change suggested by function f1 I think your code is as concise / understandable as it can be.