Find the Nth term in d series that contains only 3 & 7
eg, 3,7,33,37,73,77,333,337,373,377,.....
Input Format
A single number N
where 0 < N < 100
Output Format
The number that is in d Nth position in d series.
Sample Input
3
Sample Output
33
Explanation
3,7,33,37,..
where 33 is d 3rd number in d series.
OUTOUT:
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
int x;
scanf("%d",&x);
int i;
for(i=0;x>=pow(2,i);i++)
x=x-pow(2,i);
char s[i];
s[i]='\0';
for(i=i-1;i>=0;i--)
{
if(x%2==0)
s[i]='3';
else
s[i]='7';
if(x!=0)
x=x>>1;
}
printf("%s",s);
return 0;
}
No comments:
Post a Comment