Recursion program to find the sum of digit of a number

import java.util.*;
class SumOfDigit
{
 static int s=0,d=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= numb(n);
System.out.println("the sum of digits is "+s);
}

 static int numb(int n)
 {
 if(n!=0)
 {
 d=n%10;
 s=s+d;
 return ( numb(n/10));
 }
 else
 {
 return s;
   }
 }
}

Video/ C Introduction

Watch video in full size
Wordpress Social Share Plugin powered by Ultimatelysocial