Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //This program checks values n up to 10^10 for which the last (up to) 51 digits of 16^n are all 0,3,5,6,7,9.
- //This program was written to attempt to find a power of 2 other than 65536 which does not contain any digit 1,2,4,8.
- //This program only finds two candidates (n=7525657339 and 9881236075) but checking their first few digits via the logarithm method shows that they don't work.
- //Based on http://tasvideos.org/forum/viewtopic.php?p=437945#437945
- #include <stdio.h>
- #include <stdint.h>
- #include <cmath>
- int main()
- {
- uint64_t val1=1ULL;
- uint64_t val2=0ULL;
- uint64_t val3=0ULL;
- uint64_t carry1,carry2;
- for(uint64_t i=1;i<=10000000000ULL;i++)
- {
- val1*=16ULL;
- carry1=val1/100000000000000000ULL;
- val1%=100000000000000000ULL;
- val2=val2*16ULL+carry1;
- carry2=val2/100000000000000000ULL;
- val2%=100000000000000000ULL;
- val3=val3*16ULL+carry2;
- val3%=100000000000000000ULL;
- //check last 17 digits of val1 are all 0,3,5,6,7,9
- uint64_t c=val1;
- //ones digit is always 6
- c/=10ULL;
- int flag=1;
- for(int j=1;j<=16;j++)
- {
- int digit=(int)(c%10ULL);
- if(digit==1 || digit==2 || digit==4 || digit==8)
- {
- flag=0;
- break;
- }
- c/=10ULL;
- }
- if(flag==1)
- {
- //check last 17 digits of val2 are all 0,3,5,6,7,9
- c=val2;
- for(int j=1;j<=17;j++)
- {
- int digit=(int)(c%10ULL);
- if(digit==1 || digit==2 || digit==4 || digit==8)
- {
- flag=0;
- break;
- }
- c/=10ULL;
- }
- if(flag==1)
- {
- //check last 17 digits of val3 are all 0,3,5,6,7,9
- c=val3;
- for(int j=1;j<=17;j++)
- {
- int digit=(int)(c%10ULL);
- if(digit==1 || digit==2 || digit==4 || digit==8)
- {
- flag=0;
- break;
- }
- c/=10ULL;
- }
- if(flag==1)
- printf("%llu %llu %017llu %017llu\n",i,val3,val2,val1);
- }
- }
- if(i%100000000ULL==0) printf(".");
- }
- printf("Done!");
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement