Java Program find the sum of square of digit using recursion
import java.util.*;
class RecursionDigitSquareSum
{
static int sum=0;
public static void main(String args[])
{
int n=0;
System.out.println("enter the number");
Scanner sc= new Scanner(System.in);
n=sc.nextInt();
int k=sumSq(n);
System.out.println("sum of the suqare of the digit is "+n+" is "+k);
}
static int sumSq(int n)
{
if(n>0)
{
int d=n%10;
sum=sum+d*d;
return(sumSq(n/10));
}
else
{
return sum;
}
}
}
Video/ C Introduction
Watch video in full size