Hailstone sequence: Difference between revisions

Content added Content deleted
m (→‎{{header|ARM Assembly}}: fixed inaccurate comment)
Line 850: Line 850:
=={{header|ARM Assembly}}==
=={{header|ARM Assembly}}==


Output is in hexadecimal but is otherwise correct. Only Parts 1 and 2 are included for now.
Output is in hexadecimal but is otherwise correct.
Because of the Game Boy Advance's limited screen size, only the first 4 and last 4 entries are printed to the screen. The emulator's memory dump can show the rest.
Because of the Game Boy Advance's limited screen size, only the first 4 and last 4 entries are printed to the screen. The emulator's memory dump can show the rest. In addition, the task was split into two separate programs.

===Hailstone Sequence of N equal to 27 ===


<lang ARM Assembly> .org 0x08000000
<lang ARM Assembly> .org 0x08000000
Line 1,026: Line 1,028:


[https://ibb.co/WzgWjZ9 Picture of output on VisualBoyAdvance screen]
[https://ibb.co/WzgWjZ9 Picture of output on VisualBoyAdvance screen]


===Biggest Sequence Between 2 and 100,000===
To keep this short, I'm only including the part that changed, and the output. This goes after the call to <code>ResetTextCursors</code> but before the infinite loop:

<lang ARM Assembly> mov r0,#1
bl Hailstone
mov r6,r3
mov r0,#2
mov r8,#100000
loop_getBiggestHailstone:
mov r10,r0
bl Hailstone
mov r0,r10
cmp r3,r6
movgt r6,r3 ;if greater than, store in r6
movgt r7,r0 ;if greater than, store in r7
add r0,r0,#1
cmp r0,r8
blt loop_getBiggestHailstone
adr r1,HailstoneMessage_0
bl PrintString
bl NewLine
adr r1,HailStoneMessage_1
bl PrintString
bl NewLine
mov r0,r7
bl ShowHex32
bl NewLine
adr r1,HailStoneMessage_2
bl PrintString
bl NewLine
mov r0,r6
bl ShowHex32
bl NewLine</lang>

{{out}}
<pre>
The number that makes the
biggest sequence is:
00012CE7
And that sequence has a length
of:
0000015F
</pre>

[https://ibb.co/hXm7cJ3 Output of second program on VisualBoyAdvance's screen]


=={{header|Arturo}}==
=={{header|Arturo}}==