Digit fifth powers: Difference between revisions
Content deleted Content added
PicoLisp version |
Not a robot (talk | contribs) Add Comal |
||
Line 578:
ADD-DIGIT-POWER.
COMPUTE POWER-SUM = POWER-SUM + DIGITS(DIGIT) ** 5.</lang>
{{out}}
<pre> 4150
4151
54748
92727
93084
194979
------ +
443839</pre>
=={{header|Comal}}==
<lang comal>0010 FUNC sum5(n) CLOSED
0020 sum:=0
0030 WHILE n>0 DO sum:+(n MOD 10)^5;n:=n DIV 10
0040 RETURN sum
0050 ENDFUNC sum5
0060 //
0070 max:=9^5*6
0080 total:=0
0090 FOR i:=2 TO max DO
0100 IF i=sum5(i) THEN
0110 PRINT USING "######":i
0120 total:+i
0130 ENDIF
0140 ENDFOR i
0150 PRINT "------ +"
0160 PRINT USING "######":total
0170 END</lang>
{{out}}
<pre> 4150
|