Preview (2 of 4 Pages)100%Purchase to unlockPage 1Loading page ...CSC245RecursionLabForeachofthefollowing,writerecursivefunctionstocompletethestatedtasks.Testyourfunctionsbylettingyourmainfunctioncalltherecursivefunctionandreporttheresults.1.Givenanarrayofnintegervalues,computethesumofthevalues.Answer:/****Q1**@paramn*@return*/publicstaticintsum(intn){if(n==0){return0;}elsereturn(n+sum(n-1));}2.Outputthefollowingpatterns:a.********************(annxmrectangle)********************Answer:/****2.afunction**@paramn*@paramm*@return*/publicstaticStringrectangle(intn,intm){if(n==0){return"";}for(inti=0;i<m;i++){System.out.print("*");}System.out.println();returnrectangle(n-1,m);Page 2Preview ModeThis document has 4 pages. Sign in to access the full document!Download Now!Report