void fillArray(int*arr) { int i,counter=0; for(i=30;counter!=1001;i++) if(isLucky(i)) arr[counter++]=i; }
/*Driver function to test above function*/ int main() { int x = 5; if( isLucky(x) ) printf("%d is a lucky no.", x); else printf("%d is not a lucky no.", x); getchar(); }
int main(){ const int L = 8; long a; scanf("%ld", &a); for(int p = 1; p <= 1000; p++){ if(isLucky(a + p, L)){printf("%d\n", p); break;} } return 0; }
int construct(int a) { for(int b = a + 1; b <= 100; b++) { if(isLucky(a ^ b)) { return b; } } return -1; }
/* Returns 1 if n is a lucky no. ohterwise returns 0*/ bool isLucky(int n) { static int counter = 2; /*variable next_position is just for readability of the program we can remove it and use n only */ int next_position = n; if(counter > n) return 1; if(n%counter == 0) return 0; /*calculate next position of input no*/ next_position -= next_position/counter; counter++; return isLucky(next_position); }
long long luckyfloor(char *b){ if(isLucky(b)){ return toBits(b); } return luckyceil(b)-1; }