Entropy/Narcissist: Difference between revisions
Content added Content deleted
(Added XPL0 example.) |
No edit summary |
||
Line 183: | Line 183: | ||
{{Output}} |
{{Output}} |
||
<pre>bytes 158 entropy 5.2802</pre> |
<pre>bytes 158 entropy 5.2802</pre> |
||
=={{header|BBC BASIC}}== |
|||
{{works with|BBC BASIC for Windows}} |
|||
<syntaxhighlight lang="bbcbasic"> DIM Freq%(255) |
|||
FOR I%=PAGE TO LOMEM Freq%(?I%)+=1 NEXT |
|||
Size=LOMEM - PAGE |
|||
FOR I%=0 TO 255 |
|||
IF Freq%(I%) Entropy+=Freq%(I%) / Size * LN(Freq%(I%) / Size) / LN(2) |
|||
NEXT |
|||
PRINT "My size is ";Size " bytes and my entropy is ";-Entropy "!" |
|||
END</syntaxhighlight> |
|||
{{out}} |
|||
<pre>My size is 224 bytes and my entropy is 5.11257089!</pre> |
|||
=={{header|C}}== |
=={{header|C}}== |