View Code of Problem 3700

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

Double click to view unformatted code.


Back to problem 3700