Proper divisors: Difference between revisions

no edit summary
m (syntax highlighting fixup automation)
No edit summary
Line 2,799:
 
[15120, 18480] have 79 factors
</pre>
 
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">
 
local fn ProperDivisors( n as long ) as CFArrayRef
CFMutableArrayRef array = fn MutableArrayWithCapacity(0)
if ( n < 2 ) then exit fn
long i
for i = 1 to n - 1
if ( n mod i == 0 )
MutableArrayAddObject( array, @(i) )
end if
next
end fn = array
 
void local fn DoIt
long n, count, num, max = 0
for n = 1 to 10
printf @"%2ld: %@",n,fn ArrayComponentsJoinedByString( fn ProperDivisors( n ), @" " )
next
for n = 1 to 20000
count = len( fn Properdivisors( n ) )
if ( count > max )
max = count
num = n
end if
next
print: print num;@" has the most proper divisors with ";max
end fn
 
fn DoIt
 
HandleEvents
</syntaxhighlight>
 
{{out}}
<pre>
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
 
15120 has the most proper divisors with 79
</pre>
 
416

edits