I think it would be much better to write it in another language, but here’s another way to do the second one (this is on Visual Basic):
<pre style="background-color:#ffffff;">
<span style="color:#323232;">Dim n as long
</span><span style="color:#323232;">Dim product as long
</span><span style="color:#323232;">Product = 1
</span><span style="color:#323232;">
</span><span style="color:#323232;">For n = 1 to 4
</span><span style="color:#323232;">Product = product * 2 * n
</span><span style="color:#323232;">Next n
</span>
How i feel on Lemmy (programming.dev)
Random internet people explaining math better then math teacher (i.imgur.com)