int main() { bi_initialize(); int k = 2; bigint f1 = int_to_bi(1), f2 = int_to_bi(1), f3, tmp; bigint zeros = int_to_bi(1000000000); while (1) { k++; f3 = bi_add(f1, bi_copy(f2)); int mod = bi_int_mod(bi_copy(f3), 1000000000); if (mod >= 100000000) { if (is_pandigital(mod)) { tmp = bi_copy(f3); while (bi_compare(bi_copy(tmp), bi_copy(zeros)) > 0) { tmp = bi_int_divide(tmp, 10); } if (is_pandigital(bi_to_int(tmp))) { break; } } } f1 = f2; f2 = f3; } bi_free(f2); bi_free(f3); bi_free(zeros); printf("%d\n", k); bi_terminate(); return 0; }
int main() { double base = (1 + sqrt(5)) / 2.0; double norm = sqrt(5); int prev_lower = 1; int curr_lower = 1; int idx = 2; double high = (base * base) / norm; while(1) { int tmp = curr_lower; curr_lower = (prev_lower + curr_lower) % bound; prev_lower = tmp; high *= base; if (high >= bound) { high /= 10; } idx++; if (!is_pandigital(curr_lower)) { continue; } if (!is_pandigital((int)high)) { continue; } std::cout << idx << std::endl; break; } return 0; }
long solve() { long n = 5; long max = 7000001; while (n <= 7654321) { n += 2; if (is_pandigital(n) && common::is_prime_fast(n)) { max = n; } n += 4; if (is_pandigital(n) && common::is_prime_fast(n)) { max = n; } } return max; }
int main(){ for(int i = 9487; i >= 9234; --i){ int num = concat(i, 2*i); if(is_pandigital(num)){ std::cout << num << std::endl; break; } } }
int main(){ std::set<int> products; for(int i = 2; i <= 100; i++){ for(int j = 100; j <= 9999; j++){ if(is_pandigital(i, j)) products.insert(i * j); } } std::cout << std::accumulate(products.begin(), products.end(), 0) << std::endl; return 0; }
int main() { long p = 0; for (long x = 9387; x >= 9234; --x) { p = concat(x, 2 * x); if (is_pandigital(p)) break; } printf("%ld\n", p); return 0; }
long consec(long x) { int n = 1; long ans = 0; while(ans < 100000000) { ans = concat(ans, x * n); n++; } if(is_pandigital(ans)) return ans; else return -1; }
int main() { // NOTE: Unfortunately, I didn't figure the starting number out myself; // I used 987654321 (which takes A LOT longer, about 4.5 minutes). // Apparently, if the digital sum of a number is divisible by 3, the number isn't prime. #define START 7654321 for (uint32_t i = START; i > 0 && i <= START; i-=2) { /* detect underflow w/ i <= START */ if (is_pandigital(i) && isprime(i)) { printf("Answer: %u\n", i); break; } } return 0; }
int main(int argc, char* argv) { __int8* prime_list = create_prime_list(MAX); for (unsigned long long i = MAX; i >= 0; i--) { if (is_prime(prime_list, i) && is_pandigital(i)) { printf("Pandigital + Prime: %llu\n", i); break; } } destroy_prime_list(prime_list); return 0; }
int main(void) { initialize_primes(); for(long long i = 987654321; i > 1; i--) { if(is_pandigital(i) && is_prime(i)) { printf("%lld\n", i); return 0; } } return 1; }
int main(int argc, char* argv[]) { int n; long long int largest = 0; for (n=2; n<10; n++) { int i = 1; long long int p; while ((p = product(i, n)) < 1000000000LL) { if (is_pandigital(p)) { if (p > largest) largest = p; } i++; } } printf("%lli\n", largest); return 0; }
int main(int argc, char **argv) { int aux, max = 0; char n[MAX_DIGITS + 1]; for(int i = 9123; i < 9876; i++) { sprintf(n, "%d%d", i, 2*i); if(is_pandigital(n)) { aux = atoi(n); if(aux > max) max = aux; } } printf("%d\n", max); return 0; }
int main(void) { printf("%i\n", is_pandigital(88) ); printf("%i\n", is_pandigital(87) ); printf("%i\n", is_pandigital(75423) ); printf("%i\n", is_pandigital(453124) ); printf("%i\n", is_pandigital(2143) ); printf("%i\n", is_pandigital(625314) ); exit(0); }
int main(void) { int lim = 100000000; //9876543; //21; int *primes = malloc( lim * sizeof(int) ); sleeve(primes, lim); int i = 1000; int best = 0; while( lim -i ) { if ( primes[i] && is_pandigital(i) ) best = i; i++; } printf("%i\n",best); free(primes); exit(0); }
int main(int argc, char ** argv) { int a, b, product, sum; int * set, set_size, set_capacity; set_capacity = 2; set_size = 0; set = (int *) malloc(set_size * sizeof(int)); for(a = 1; a < 100000; a++) { if(!is_pandigital(a)) continue; for(b = a + 1; b < 100000 / a; b++) { product = a * b; if(a * b > 100000) break; if(is_pandigital3(a, b, product)) { //printf("%d * %d == %d\n", a, b, product); set_append(set, &set_size, &set_capacity, product); } } } sum = 0; for(a = 0; a < set_size; a++) sum += set[a]; printf("Sum of 1-9 pandigital products: %d\n", sum); free(set); return 0; }
int main(int argc, char *argv[]) { int num, concat, i; int found = 0; for (num = NUM_START; num > 0; num--) { concat = 0; for (i = 1; ndigit(concat) < 9; i++) { concat = concatnum(concat, i * num); if (ndigit(concat) == 9 && is_pandigital(concat)) { found = 1; break; } } if (found) break; } if (!found) errx(1, "oops! not found..."); printf("%d\n", concat); return 0; }