Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Code:
- #include<iostream>
- #include<stdio.h>
- using namespace std;
- int power(int n, int i)
- {
- if(i==0) return 1;
- else return n*power(n,i-1);
- }
- void assigndectohex(int*a, int n)
- {
- for(int i=7;i>=0;i--)
- {
- a[i]=n%6;
- n=n/6;
- }
- }
- int hextodec(int*a)
- {
- int n=0;
- for(int i=0;i<8;i++)
- n=n+a[i]*power(6,i);
- return n;
- }
- int main()
- {
- FILE*fp=fopen("omo39out.txt","w");
- int a[8][8], flag,count;
- for(int n=1;n<=1679615;n++)
- {
- flag=1;
- assigndectohex(a[0],n);
- for(int i=1;i<8;i++)
- {
- for(int j=0;j<8;j++)
- {
- a[i][(j+7)%8]=a[i-1][j];
- }
- }
- for(int i=1;i<8;i++)
- {
- if((hextodec(a[i])%hextodec(a[0]))!=0)
- {
- flag=0; break;
- }
- }
- if(flag==1)
- {
- count++;
- for(int i=0;i<8;i++)
- {fprintf(fp,"%d", a[0][i]);}
- fprintf(fp,"\n");
- }
- }
- fclose(fp);
- printf("So count of such numbers=%d",count);
- return 0;
- }
- //Output:
- 10000000
- 10001000
- 10100000
- 10101010
- 11000000
- 11001100
- 11110000
- 11111111
- 20000000
- 20002000
- 20200000
- 20202020
- 22000000
- 22002200
- 22220000
- 22222222
- 30000000
- 30003000
- 30300000
- 30303030
- 33000000
- 33003300
- 33330000
- 33333333
- 40000000
- 40004000
- 40400000
- 40404040
- 44000000
- 44004400
- 44440000
- 44444444
- 50000000
- 50005000
- 50500000
- 50505050
- 55000000
- 55005500
- 55550000
- 46
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement