Babbage problem: Difference between revisions
m
reorder solution
m (→{header|J}) |
m (reorder solution) |
||
Line 69:
<pre>25264</pre>
=={{header|J}}==▼
The key to understandability is a mix of hopefully adequate notation and some level of verifiability.▼
So let's break the implementation into some named pieces and present enough detail that a mathematician can verify that the result is both consistent and reasonable:▼
<lang J> square=: ^&2▼
modulo1e6=: 1000000&|▼
trythese=: i. 1000000 NB. first million nonnegative integers▼
which 269696=modulo1e6 square trythese NB. right to left <-▼
25264 99736 150264 224736 275264 349736 400264 474736 525264 599736 650264 724736 775264 849736 900264 974736</lang>▼
=={{header|Processing}}==
<lang java>// Lines that begin with two slashes, thus, are comments: they
Line 106 ⟶ 119:
{{out}}
<pre>25264</pre>
▲=={{header|J}}==
▲The key to understandability is a mix of hopefully adequate notation and some level of verifiability.
▲So let's break the implementation into some named pieces and present enough detail that a mathematician can verify that the result is both consistent and reasonable:
▲<lang J> square=: ^&2
▲ modulo1e6=: 1000000&|
▲ trythese=: i. 1000000 NB. first million nonnegative integers
▲ which 269696=modulo1e6 square trythese NB. right to left <-
▲25264 99736 150264 224736 275264 349736 400264 474736 525264 599736 650264 724736 775264 849736 900264 974736</lang>
▲The smallest of these values is 25264,
|