以下是生成循环的shell程序
- #!/bin/bash
- echo $1|awk '{x=$1;n=0;}
- {
- for(i=1;i<=x*2;i+=1)
- b[i]=1;
- for(i=1;i<=2*x;i++)
- if(b[i] == 0)
- continue;
- else {
- b[i]=0;
- y=i;
- s=i;
- j=i;
- while(1) {
- if(j>x)
- j=2*(j-x);
- else
- j=j*2-1;
- if(j==y)
- break;
- s=s","j;
- b[j]=0;
- }
- S[n++]="("s")";
- }
- for(i=0;i<n;i++)
- print S[i];
- }'
复制代码 比如当n=256时,
该置换是以下循环的乘积,很复杂
- (1)
- (2,3,5,9,17,33,65,129,257)
- (4,7,13,25,49,97,193,385,258)
- (6,11,21,41,81,161,321,130,259)
- (8,15,29,57,113,225,449,386,260)
- (10,19,37,73,145,289,66,131,261)
- (12,23,45,89,177,353,194,387,262)
- (14,27,53,105,209,417,322,132,263)
- (16,31,61,121,241,481,450,388,264)
- (18,35,69,137,273,34,67,133,265)
- (20,39,77,153,305,98,195,389,266)
- (22,43,85,169,337,162,323,134,267)
- (24,47,93,185,369,226,451,390,268)
- (26,51,101,201,401,290,68,135,269)
- (28,55,109,217,433,354,196,391,270)
- (30,59,117,233,465,418,324,136,271)
- (32,63,125,249,497,482,452,392,272)
- (36,71,141,281,50,99,197,393,274)
- (38,75,149,297,82,163,325,138,275)
- (40,79,157,313,114,227,453,394,276)
- (42,83,165,329,146,291,70,139,277)
- (44,87,173,345,178,355,198,395,278)
- (46,91,181,361,210,419,326,140,279)
- (48,95,189,377,242,483,454,396,280)
- (52,103,205,409,306,100,199,397,282)
- (54,107,213,425,338,164,327,142,283)
- (56,111,221,441,370,228,455,398,284)
- (58,115,229,457,402,292,72,143,285)
- (60,119,237,473,434,356,200,399,286)
- (62,123,245,489,466,420,328,144,287)
- (64,127,253,505,498,484,456,400,288)
- (74,147,293)
- (76,151,301,90,179,357,202,403,294)
- (78,155,309,106,211,421,330,148,295)
- (80,159,317,122,243,485,458,404,296)
- (84,167,333,154,307,102,203,405,298)
- (86,171,341,170,339,166,331,150,299)
- (88,175,349,186,371,230,459,406,300)
- (92,183,365,218,435,358,204,407,302)
- (94,187,373,234,467,422,332,152,303)
- (96,191,381,250,499,486,460,408,304)
- (104,207,413,314,116,231,461,410,308)
- (108,215,429,346,180,359,206,411,310)
- (110,219,437,362,212,423,334,156,311)
- (112,223,445,378,244,487,462,412,312)
- (118,235,469,426,340,168,335,158,315)
- (120,239,477,442,372,232,463,414,316)
- (124,247,493,474,436,360,208,415,318)
- (126,251,501,490,468,424,336,160,319)
- (128,255,509,506,500,488,464,416,320)
- (172,343,174,347,182,363,214,427,342)
- (176,351,190,379,246,491,470,428,344)
- (184,367,222,443,374,236,471,430,348)
- (188,375,238,475,438,364,216,431,350)
- (192,383,254,507,502,492,472,432,352)
- (220,439,366)
- (224,447,382,252,503,494,476,440,368)
- (240,479,446,380,248,495,478,444,376)
- (256,511,510,508,504,496,480,448,384)
- (512)
复制代码 |