Digit fifth powers: Difference between revisions

Add Cowgol
(Add J)
(Add Cowgol)
Line 244:
194979
Total is 443839</pre>
 
=={{header|Cowgol}}==
<lang cowgol>include "cowgol.coh";
 
sub pow5(n: uint32): (p: uint32) is
p := n*n * n*n * n;
end sub;
 
sub sum5(n: uint32): (r: uint32) is
r := 0;
while n != 0 loop
r := r + pow5(n % 10);
n := n / 10;
end loop;
end sub;
 
var total: uint32 := 0;
var n: uint32 := 2;
var max: uint32 := pow5(9) * 6;
 
while n <= max loop
if n == sum5(n) then
total := total + n;
print_i32(n);
print_nl();
end if;
n := n + 1;
end loop;
 
print("Total: ");
print_i32(total);
print_nl();</lang>
{{out}}
<pre>4150
4151
54748
92727
93084
194979
Total: 443839</pre>
 
=={{header|Factor}}==
2,093

edits