      SUBROUTINE SMFAC (IFACT,NFACT,ISYM,IFSYM,NFSYM,ICENT,IFCNT,NFCNT) 
C     REARRANGE THE PRIME FACTORS OF N INTO A SQUARE AND A NON- 
C     SQUARE.  N = ISYM*ICENT*ISYM, WHERE ICENT IS SQUARE-FREE. 
C     ISYM = IFSYM(1)*...*IFSYM(NFSYM), EACH A PRIME FACTOR.
C     ICENT = IFCNT(1)*...*IFCNT(NFCNT), EACH A PRIME FACTOR. 
C     FOR EXAMPLE, N = 1960 = 14*10*14.  THEN ISYM = 14, ICENT = 10,
C     NFSYM = 2, NFCNT = 2, NFACT = 6, IFSYM(IFS) = 2, 7, IFCNT(IFC) =
C     2, 5 AND IFACT(IF) = 2, 7, 2, 5, 7, 2.
      IMPLICIT REAL (A-H,O-Z),
     +INTEGER (I-N)
      DIMENSION IFSYM(1), IFCNT(1), IFACT(1)
      ISYM=1
      ICENT=1 
      IFS=0 
      IFC=0 
      IF=1
 10   IF (IF-NFACT) 20,40,50
 20   IF (IFACT(IF)-IFACT(IF+1)) 40,30,40 
 30   IFS=IFS+1 
      IFSYM(IFS)=IFACT(IF)
      ISYM=IFACT(IF)*ISYM 
      IF=IF+2 
      GO TO 10
 40   IFC=IFC+1 
      IFCNT(IFC)=IFACT(IF)
      ICENT=IFACT(IF)*ICENT 
      IF=IF+1 
      GO TO 10
 50   NFSYM=IFS 
      NFCNT=IFC 
      NFSM2=2*NFSYM 
      NFACT=2*NFSYM+NFCNT 
      IF (NFCNT) 80,80,60 
 60   NFSM2=NFSM2+1 
      IFSYM(NFSYM+1)=ICENT
      DO 70 IFC=1,NFCNT 
      IF=NFSYM+IFC
 70   IFACT(IF)=IFCNT(IFC)
 80   IF (NFSYM) 110,110,90 
 90   DO 100 IFS=1,NFSYM
      IFSCJ=NFSM2+1-IFS 
      IFSYM(IFSCJ)=IFSYM(IFS) 
      IFACT(IFS)=IFSYM(IFS) 
      IFCNJ=NFACT+1-IFS 
 100  IFACT(IFCNJ)=IFSYM(IFS) 
 110  NFSYM=NFSM2 
      RETURN
      END 
