Proper divisors: Difference between revisions

Content added Content deleted
(→‎{{header|Java}}: Change for the special case of n = 1)
Line 32: Line 32:


=={{header|J}}==
=={{header|J}}==
{{incorrect|J|1 has no proper divisors.}}


The proper divisors of an integer are the [[Factors of an integer]] without the integer itself.
The proper divisors of an integer are the [[Factors of an integer]] without the integer itself.
Line 39: Line 38:


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


Proper divisors of numbers 1 through 10:
Proper divisors of numbers 1 through 10:


<lang J> (,&": ' -- ' ,&": properDivisors)&>1+i.10
<lang J> (,&": ' -- ' ,&": properDivisors)&>1+i.10
1 -- 1
1 --
2 -- 1
2 -- 1
3 -- 1
3 -- 1