Hi,

1.find the sum of the digits of the number
[acc. to fact that number+9 has the same sum of the digits as number]
2.  for i=sum_of_the_digits_of_the_number; i<=number; i=i+9
   3.find if number is divisible by i then print it


code:
#include<stdio.h>

int sum_of_the_digits(int n)
{
if(n==0)
return 0;
return (n%10 + sum_of_the_digits(n/10));
}

int main()
{
int a;
printf("Enter the number:");
scanf("%d",&a);
int i;
for(i=sum_of_the_digits(a);i<=a;i+=9)
if(a%i==0)
{
printf("%d",i);
break;
}
return 0;
}

Regards,
Karthikeyan.V.B
PSGTECH
CBE

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to