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

 

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

Given an equation x1 + x2 +· · ·+xn = C, where C is a constant, and x1, x2, . . . , xn are nonnegative integers, how many solutions are there? I THINK THE PARAMETERS ARE BACKWARDS BUT IT'S TOO LATE TO CHANGE IT


countSolutions(8, 3) → 45
countSolutions(2, 2) → 3
countSolutions(3, 2) → 4

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

public int countSolutions(int n, int c) { }

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

Copyright Nick Parlante 2017 - privacy