LacRecursivsSqureSum
package Lab7;public class LacRecursivsSqureSum
{
public static void main(String[] args)
{
System.out.println("squreSum()"+squreSum(5));
}
public static int squreSum(int n)
{
if(n==1)
{
return 1;
}
else
{
return (squreSum(n-1)+n*n);
}
}
}
0 Comments:
張貼留言
<< Home