
Basic Data Operation

This is a basic data operation. It represents a fundamental action on a basic data type.
You may see other such operations in the Basic Data Operations category, or:


Integer Operations
Arithmetic |
Comparison
Boolean Operations
Bitwise |
Logical
String Operations
Concatenation |
Interpolation |
Comparison |
Matching
Memory Operations
Pointers & references |
Addresses


Task

Compute the   factors   of a positive integer.

These factors are the positive integers by which the number being factored can be divided to yield a positive integer result.

(Though the concepts function correctly for zero and negative integers, the set of factors of zero has countably infinite members, and the factors of negative integers can be obtained from the factors of related positive numbers without difficulty;   this task does not require handling of either of these cases).

Note that every prime number has two factors:   1   and itself.



Related tasks

   count in factors
   prime decomposition
   Sieve of Eratosthenes
   primality by trial division
   factors of a Mersenne number
   trial factoring of a Mersenne number
   partition an integer X into N primes
   sequence of primes by Trial Division
   sequence: smallest number greater than previous term with exactly n divisors


*        Factors of an integer -   07/10/2015
FACTOR   CSECT
         USING  FACTOR,R15         set base register
         LA     R7,PG              pgi=@pg
         LA     R6,1               i
         L      R3,N               loop count
LOOP     L      R5,N               n
         LA     R4,0
         DR     R4,R6              n/i
         LTR    R4,R4              if mod(n,i)=0
         BNZ    NEXT
         XDECO  R6,PG+120          edit i
         MVC    0(6,R7),PG+126     output i
         LA     R7,6(R7)           pgi=pgi+6
NEXT     LA     R6,1(R6)           i=i+1
         BCT    R3,LOOP            loop
         XPRNT  PG,120             print buffer
         XR     R15,R15            set return code
         BR     R14                return to caller
N        DC     F'12345'           <== input value
PG       DC     CL132' '           buffer
         YREGS
         END    FACTOR