subroutine r4_factor ( n, nf, fac ) !*****************************************************************************80 ! !! R4_FACTOR factors of an integer for real single precision computations. ! ! ! Copyright (C) 1995-2004, Scientific Computing Division, ! University Corporation for Atmospheric Research ! ! Modified: ! ! 27 August 2009 ! ! Author: ! ! Paul Swarztrauber ! Richard Valent ! ! Reference: ! ! Paul Swarztrauber, ! Vectorizing the Fast Fourier Transforms, ! in Parallel Computations, ! edited by G. Rodrigue, ! Academic Press, 1982. ! ! Paul Swarztrauber, ! Fast Fourier Transform Algorithms for Vector Computers, ! Parallel Computing, pages 45-63, 1984. ! ! Parameters: ! ! Input, integer ( kind = 4 ) N, the number for which factorization and ! other information is needed. ! ! Output, integer ( kind = 4 ) NF, the number of factors. ! ! Output, real ( kind = 4 ) FAC(*), a list of factors of N. ! implicit none real ( kind = 4 ) fac(*) integer ( kind = 4 ) j integer ( kind = 4 ) n integer ( kind = 4 ) nf integer ( kind = 4 ) nl integer ( kind = 4 ) nq integer ( kind = 4 ) nr integer ( kind = 4 ) ntry nl = n nf = 0 j = 0 do while ( 1 < nl ) j = j + 1 if ( j == 1 ) then ntry = 4 else if ( j == 2 ) then ntry = 2 else if ( j == 3 ) then ntry = 3 else if ( j == 4 ) then ntry = 5 else ntry = ntry + 2 end if do nq = nl / ntry nr = nl - ntry * nq if ( nr /= 0 ) then exit end if nf = nf + 1 fac(nf) = real ( ntry, kind = 4 ) nl = nq end do end do return end