Z<-SHUFFLE_CARDS STR;CNT;N;JX;A;QIN;QV |Shuffle pack of N cards |Compute the cycle of shuffle |See Ian Stewart. Scientific American , Nov 1998 QIN<-QV<-0 & STR<-"52" #ifndef "STR" STR<-"-cycle QV<-1|-in QIN<-1" GETOPTS STR N<-#fi STR Z<-y(2,N%2)riN | out shuffle IF QIN;Z<-mZ | in Shuffle Z<-,Z & IF ~QV; ->0 A<-iN & CNT<-1 WHILE QV;BREAKIF (iN) #equiv A<-A[Z];CNT++;WEND Z<-CNT Z<-GPERM S;K;N |Permutations of the set S N<-rS & K<-0 & Z<-i0 WHILE KBB J<-(Z=C)/iN & Z[J]<- K |Adjust component number T<-T,"(",(zJ),")" S<-S,rJ WEND IF 0 < FC <-0 #ifndef "FC"; Z<-S; ->0 Z<-T Z<-P_MULT STR;IDX;NR;TAB |Mapping composition of permutations Z<-#deb STR<-"" #ifndef "STR" NR<-1tr:TAB<-#sstomat " ", STR Z<-$NL[#deb TAB[IDX<-NR-1 :]] WHILE 0 < IDX--; Z<-($NL[#deb TAB[IDX:]])[Z]; WEND ZA<-JMULT STR |Mapping composition of permutations |Each permutation is entered as a single letter. IF 0=r ZA<- STR<-"" #ifndef "STR"; ->0 ZA<-$NL[1tSTR] & STR<-1dSTR WHILE 0 < r STR; ZA<-($NL[1tSTR])[ZA]; STR<-1dSTR; WEND Z<-G_ORDER X;T;N |Order Z of permutation X. X^Z=1 Z<-1; N<-irT<-X WHILE ~ T #equiv N; Z++; T<-T[X]; WEND Z<-M12 STR |Two generators for M12 Z<-STR<-"AB" #ifndef "STR" $NL[STR[0]]<-mi12 $NL[STR[1]]<- ,y 2 6 r (i6),6+mi6 Z<-N GEN2 STR;K |Two generators : reverse + shuffle N<-12 #ifndef "N" Z<-STR<-"AB" #ifndef "STR" K<-N%2 $NL[STR[0]]<-mi2*K $NL[STR[1]]<- ,y (2,K) r (iK),K+miK Z<-X CV Y;I;J;N;T |Convolution or polynomial multiplication Z<-iI<-0 & N<-1+c/J<-,(irX) #outer+ irY & T<-,X #outer* Y AA: Z<-Z,+/(I=J)/T & I++ & ->(I(0=rIX)/0 ->(10 AA: |Split N<-(rIX)%2 Z<-(CV_PRODUCT NtIX) CV CV_PRODUCT NdIX Z<-MAX CV_ALT_PRODUCT SIX;N |Product (1+s[0]*x^i[0])(1+s[1]*x^i[1])... |s[k] + or - signs |i[k] indices MAX<-50 #ifndef "MAX" | Truncate series Z<-1; IF 0 = r SIX; ->0 IF 2 = r SIX; Z<-(1, (SIX[1]-1), 1)/1 0, SIX[0]; ->0 N<-(rSIX)%2; N<-2*N%2 Z<-(MAX CV_ALT_PRODUCT N t SIX) CV MAX CV_ALT_PRODUCT N d SIX IF MAX < rZ; Z<-MAX t Z | Truncate Z<-N P_INV A |Inverse of series a[0]+a[1]x+a[2]x*x.... |assume a[0]=1 Z<-1 & N<-20 #ifndef"N" WHILE N>rZ;Z<-Z,-+/(mZ)*(rZ)t1dA;WEND Z<-N LI_INV A;K |Inverse of series a[0]+a[1]x+a[2]x*x.... |assume a[0]=1 |Give Z as a string of Long Int. Z<-"1" & K<-1; N<-20 #ifndef"N" WHILE K0 Z<-NP LI_INV Z Z<-(#sstomat " ",Z)[iN+1] Z<-TAU N |Ramanujan numbers |Expand (Product (1-x^2n))^24 Z<-N CV_ALT_PRODUCT ,_1, y1+iN Z<-N t Z CV Z CV Z |P^3 Z<-CV_XSQ 1.0*Z Z<-CV_XSQ Z Z<-CV_XSQ Z Z<-S_NEXT X;K |Next partition of N = +/X in lexicographic order IF 1 >= rZ<-X; ->0 IF X[_2+rX] = K<-X[0]; Z<-K, ((+/X)-K<-1+X[0])/1; ->0 Z<-K, S_NEXT 1dX; Z<-LIST_PARTS N;X;Y |List partitions of N as a P(N) x N matrix IF N>25; Z<-"sanity check"; ->0 Z<-X<-Nr1 WHILE ~ X #equiv Y<- S_NEXT X Z<-Z,:N t X<-Y WEND Z<-DISP_PARTS N;H;X;Y |List partitions of N as a P(N) histograms IF N>20; Z<-"sanity check"; ->0 Z<-X<-Nr1 WHILE ~ X #equiv Y<- S_NEXT X H<-".O" [(N,N) t #theta(iN) #outer < X] H #wput 0 0,rH 0 r #sleep 0 800000 X<-Y WEND "shuffle.txt" << EOF Marcus Du Sautoy and moonshine. Groups of order 3^3. Search for a function f:N->N which enumerates finite groups of order n. In the case of Abelian groups a partial solution is possible. The number of groups of order p^n is P(n) the partition function. (Sloane, encyclopedia of integer sequences.) For abelian group enumeration try dirichlet series Product (Zeta(ns)) n=1 to infinity. There are also functions to evaluate coefficients of powers of A(x)=Product(1+x^n) B(x)=Product(1-x^n) C(x)=Product(1+x^2n-1) D(x)=Product(1-x^2n-1) Try (C^8-D^8)%16 against x A(x^2) EOF Z<-SEQ_8 STR;E;N;OFILE;T |Products (1+x^n)^8 OFILE<-"" N<-50 STR<-"-o OFILE<-SHIFT" GETOPTS STR IF 0x^k K<-2 #ifndef "K" Z<-K/X Z<-(rX) r Z* (rZ) r Kt1 Z<-FXY_SERIES STR;CNT;EXPR;M;T;X;Y |Count points for which f(x,y)=0 (mod M) Z<-1 1;M<-2;CNT<-50 EXPR<-"-cnt CNT<-#fi SHIFT" GETOPTS STR WHILE CNT >= rZ T<-iM,M Y<-T[:0]; X<-T[:1] 0 r #do "T<-",EXPR Z<-Z,+/0=T #mod M M++ WEND