Anonymous user
Perfect numbers: Difference between revisions
m
formatting
(→{{header|Smalltalk}}: + Tcl) |
m (formatting) |
||
Line 3:
A number is perfect if the sum of its factors is equal to twice the number. An equivalent condition is that <tt>n</tt> is perfect if the sum of <tt>n</tt>'s factors that are less than <tt>n</tt> is equal to <tt>n</tt>.
Note: The faster [[Lucas-Lehmer_test]] is used to find primes of the form
=={{header|Ada}}==
Line 335:
=={{header|Tcl}}==
<lang tcl>proc perfect n {
set sum 0
for {set
}▼
expr {$sum == 2*$n}▼
▲ }
}</lang>▼
▲ expr {$sum == 2*$n}
▲</lang>
|