Wednesday, 10 September 2014
Tuesday, 9 September 2014
Sunday, 7 September 2014
Monday, 1 September 2014
Thursday, 17 July 2014
Three times the sum of digits of the number equals number itself.
// num = 27 = 3*(2+7)
// AIM: To find all such numbers
#include<stdio.h>
void main()
{
long num = 1, i;
int temp = 0;
long test = 0;
long count = 0;
while(count < 100)
{
i = num;
test = 0;
while(i != 0)
{
temp = i % 10;
test = test + temp;
i = i / 10;
}
if( (test*3) == num)
{
printf("found : %d", num);
//only such number is 27, u can check upto infinite but no use, I already tried. :P
}
//printf("num = %d and test*3 = %d\n",num, test*3);
count++;
num++;
}
}
// AIM: To find all such numbers
#include<stdio.h>
void main()
{
long num = 1, i;
int temp = 0;
long test = 0;
long count = 0;
while(count < 100)
{
i = num;
test = 0;
while(i != 0)
{
temp = i % 10;
test = test + temp;
i = i / 10;
}
if( (test*3) == num)
{
printf("found : %d", num);
//only such number is 27, u can check upto infinite but no use, I already tried. :P
}
//printf("num = %d and test*3 = %d\n",num, test*3);
count++;
num++;
}
}
Thursday, 19 June 2014
Tuesday, 22 April 2014
Subscribe to:
Posts (Atom)


