How to resolve the algorithm Proper divisors step by step in the J programming language

Published on 12 May 2024 09:40 PM
#J

How to resolve the algorithm Proper divisors step by step in the J programming language

Table of Contents

Problem Statement

The   proper divisors   of a positive integer N are those numbers, other than N itself, that divide N without remainder. For N > 1 they will always include 1,   but for N == 1 there are no proper divisors.

The proper divisors of     6     are   1, 2, and 3. The proper divisors of   100   are   1, 2, 4, 5, 10, 20, 25, and 50.

Show all output here.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Proper divisors step by step in the J programming language

Source code in the j programming language

factors=: [: /:~@, */&>@{@((^ i.@>:)&.>/)@q:~&__
properDivisors=: factors -. ]


   (,&": ' -- ' ,&": properDivisors)&>1+i.10
1 --       
2 -- 1     
3 -- 1     
4 -- 1 2   
5 -- 1     
6 -- 1 2 3 
7 -- 1     
8 -- 1 2 4 
9 -- 1 3   
10 -- 1 2 5


   (, #@properDivisors)&> 1+I.(= >./) #@properDivisors@> 1+i.20000
15120 79
18480 79


      (, #@properDivisors)&> 1+I.(= >./) #@factors@> 1+i.20000
15120 79
18480 79


  

You may also check:How to resolve the algorithm Narcissistic decimal number step by step in the Racket programming language
You may also check:How to resolve the algorithm Factors of a Mersenne number step by step in the FreeBASIC programming language
You may also check:How to resolve the algorithm Loops/N plus one half step by step in the J programming language
You may also check:How to resolve the algorithm Loops/Do-while step by step in the PHL programming language
You may also check:How to resolve the algorithm SEDOLs step by step in the Julia programming language