#include<stdio.h>
#include<conio.h>
int
recsum(int n);
void
main()
{
int n,ans;
clrscr();
printf("\n enter the number");
scanf("\n %d",&n);
ans= recsum(n);
/* if(ans>9)
{
n=ans;
ans=0;
}
*/
printf("\n sum is%d",ans);
getch();
}
int recsum(int n1)
{
int rem,sum=0;
if(n1==0)
{
return 0;
}
else
{
rem=n1%10;
sum=rem+recsum(n1/10);
}
if(sum>9)
{
n1=sum;
sum=recsum(n1);
}
return sum;
}
/* output
enter the number567
sum is9
*/