Jump to content

Factors of an integer: Difference between revisions

No edit summary
Line 445:
w $$factors(64) ; [1,2,4,8,16,32,64]</lang>
 
 
=={{header|Niue}}==
 
<lang Niue>
[ 'n ; [ negative-or-zero [ , ] if
[ n not-factor [ , ] when ] else ] n times n ] 'factors ;
 
[ dup 0 <= ] 'negative-or-zero ;
[ swap dup rot swap mod 0 = not ] 'not-factor ;
 
( tests )
100 factors .s .clr ( => 1 2 4 5 10 20 25 50 100 ) newline
53 factors .s .clr ( => 1 53 ) newline
64 factors .s .clr ( => 1 2 4 8 16 32 64 ) newline
12 factors .s .clr ( => 1 2 3 4 6 12 )
</lang>
 
=={{header|OCaml}}==
Line 451 ⟶ 467:
let factors n =
List.filter (fun v -> (n mod v) = 0) (range n)</lang>
 
 
=={{header|Oz}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.