This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch, libfortran] Fix PR 36302


Tobias Burnus wrote:

PS: gfortran seems to be one of the very few compilers which supports INTEGER(16) - all my other compilers don't. I really wonder why.

You bet ! Try this one:


      integer*16 i, j, k, n
      integer*16 ipf(3,30)
      character*80 arg
      call getarg(1, arg)
      read(arg, '(i40)') n
      ipf = 0
      i = 1
      k = n
      j = 1
      do while (k .ge. i**2)
         if (mod(k,i) .eq. 0 .and. i .gt. 1) then
            ipf(1, j) = i
            ipf(2, j) = ipf(2, j) + 1
            k = k / i
         else
            i = i + 1
            if (ipf(2,j) .gt. 0) j = j + 1
         endif
      enddo
      if (ipf(2, j) .gt. 0 .and. ipf(1, j) .ne. k) j = j + 1
      ipf(1, j) = k
      ipf(2, j) = ipf(2, j) + 1
      print*,(ipf(2,i),' factoren',ipf(1,i),i=1,j)
      print*,'Aantal delers =',product(ipf(2,:) + 1)
      print*,1_16
      do while ( any(ipf(3,:) .ne. ipf(2,:)) )
         do i = 1, j
            if (ipf(3,i) .eq. ipf(2,i)) then
               ipf(3,i) = 0
            else
               ipf(3,i) = ipf(3,i) + 1
               exit
            endif
         enddo
         print*,product(ipf(1,:) ** ipf(3,:))
      enddo
      end

and feed it a 30 digit number ...

--
Toon Moene - e-mail: toon@moene.indiv.nluug.nl - phone: +31 346 214290
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
At home: http://moene.indiv.nluug.nl/~toon/
Progress of GNU Fortran: http://gcc.gnu.org/ml/gcc/2008-01/msg00009.html


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]