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

 

frew@mclean.com recursion-zy > sumCubeRecursive
prev  |  next  |  chance

Give a recursive algorithm to compute the sum of the cubes of the first n positive integers. The input to the algorithm is a positive integer n. The output is sum(j=1,n,j^3). The algorithm should be recursive, it should not compute the sum using a closed form expression or an iterative loop.


sumCubeRecursive(1) → 1
sumCubeRecursive(2) → 9
sumCubeRecursive(3) → 36

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

public int sumCubeRecursive(int n) { }

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

Copyright Nick Parlante 2017 - privacy