Babbage problem: Difference between revisions
Content deleted Content added
→{{header|Perl 6}}: add whitespace |
→{{header|Perl 6}}: add list comprehension solution |
||
Line 299: | Line 299: | ||
=={{header|Perl 6}}== |
=={{header|Perl 6}}== |
||
{{works with|Rakudo|2016.03}} |
{{works with|Rakudo|2016.03}} |
||
This could certainly be written more concisely. Extra verbiage is included to make the process more clear. |
This could certainly be written more concisely. Extra verbiage is included to make the process more clear. |
||
Line 310: | Line 311: | ||
print "{$integer}² equals $square" and exit if $square % 1000000 == 269696; |
print "{$integer}² equals $square" and exit if $square % 1000000 == 269696; |
||
}</lang> |
}</lang> |
||
{{out}} |
{{out}} |
||
<pre>25264² equals 638269696</pre> |
<pre>25264² equals 638269696</pre> |
||
Alternatively, the following just may be declarative enough to allow Babbage to understand what's going on: |
|||
<lang perl6>say $_ if ($_² % 1000000 == 269696) for 1..99736;</lang> |
|||
{{out}} |
|||
<pre> |
|||
25264 |
|||
99736 |
|||
</pre> |
|||
=={{header|Processing}}== |
=={{header|Processing}}== |