View Code of Problem 3700

#include <stdio.h>
#include <math.h>
int main()
{
    int a,b[100];
    while(scanf("%d",&a)!=EOF)
    {
    	int i,j,k=0,s=0;
    	if(a==0) break;
    	while(a)
    	{
    		i=a%2;
    		a=a/2;
    		b[k++]=i;
		}
		for(j=0;;j++)
		{
			if(b[j]==1) 
			{
				s=pow(2,j);
				printf("%d\n",s);
				break;
			}
		}
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 3700