Proper divisors: Difference between revisions
Content added Content deleted
ReeceGoding (talk | contribs) (→{{header|R}}: New solution.) |
ReeceGoding (talk | contribs) |
||
Line 4,319: | Line 4,319: | ||
===Filter solution=== |
===Filter solution=== |
||
<lang r> |
<lang r>#Task 1 |
||
⚫ | |||
#Has no input error checking. |
#Has no input error checking. |
||
divisors<-function(n) |
divisors<-function(n) |
||
Line 4,342: | Line 4,341: | ||
". It has ",length(divisorList[[numberWithMostDivisors]])," divisors.")) |
". It has ",length(divisorList[[numberWithMostDivisors]])," divisors.")) |
||
} |
} |
||
mostProperDivisors(20000) |
mostProperDivisors(20000)</lang> |
||
</lang> |
|||
{{Output}} |
{{Output}} |
||
⚫ | |||
<pre> |
|||
#Task 2 |
|||
> Vectorize(divisors)(1:10) |
> Vectorize(divisors)(1:10) |
||
[[1]] |
[[1]] |
||
Line 4,382: | Line 4,378: | ||
#Task 3 |
#Task 3 |
||
> mostProperDivisors(20000) |
> mostProperDivisors(20000) |
||
[1] "The number with the most divisors between 1 and 20000 is 15120. It has 79 divisors." |
[1] "The number with the most divisors between 1 and 20000 is 15120. It has 79 divisors."</pre> |
||
</pre> |
|||
=={{header|Racket}}== |
=={{header|Racket}}== |