Ada Lovelace: What did the first computer program do?

Have you ever wondered what did the first ever computer program do?
The first ever piece of code was written in 1842, well before the first actual machine that could be called a computer (you wouldn’t call it a computer if you saw it).
Author of that program was Ada Augusta, Countess of Lovelace, known to us as Ada Lovelace. As the author of the first ever computer program, she is widely regarded as the first ever programmer.
When calling Ada “a programmer”, it is easy to forget that the decade of the first code was the decade when Samuel Morse first demonstrated the telegraph, Amistad and 30th U.S. state happened, Ottoman and Persian empires, Mamelukes and Egypt fought over the middle east. The word “computer” would still mean “a person doing calculations” for at least 100 more years. That was a long time ago.
The first code was written for Charles Babbage’s Analytical Engine, which never actually got built, although might someday be. Lovelace saw the potential of Babbages machine and the idea of programmable computer.
She translated an Italian mathematician Luigi Menabrea’s essay “A Sketch of the Analytical Engine” for Taylor’s Scientific Memoirs and augmented it with “Notes by the Translator”, which explain what the Charles Babbage’s Analytical Engine is capable of.
The beginning of Note G, which contains the mentioned first ever computer program, illustrates how Lovelace was aware of how profound Babbage’s design was, but kept her scientific calm.
“It is desirable to guard against the possibility of exaggerated ideas that might arise as to the powers of the Analytical Engine”
There’s absolutely no way Lovelace could in her wildest dreams possibly have exaggerated the powers of what essentially was a design containing essential parts of modern computer.
Babbage’s refusal to publish much concrete about his machine left Lovelace’s notes as the main influence on future developments, most notably the work by Alan Turing to lay out the idea of universal stored-program computer.
That was something Ada never got to see. She died at age of 36 and previously mentioned notes remained her only publication. Would computers be different had she lived and worked longer?
Let’s get back to the question. What would the first computer program have done if Babbage would have had enough resources to actually build an Analytic Engine for Lovelace to run her program on it? The program made Babbage’s engine calculate a sequence of Bernoulli numbers. In the note Lovelace derives a formula, which essentially is the traditional recursive definition of Bernoulli numbers.
Then she goes on to describe how to implement it in punch cards Analytical Engine was supposed to use as input. In her implementation Lovelace assumes the series of “first Bernoulli” numbers (B0=1, B1=-½, …) and starts calculating the series from B2 (the first “non-trivial” Bernoulli number), which she labels as B1.
A contemporary interpretation of Ada's punch card stack using JavaScript might resemble the following. This version doesn't replicate Ada's code for the Analytic Engine but rather reinterprets the algorithm she employed.
Interestingly, there haven't been any identified bugs in Ada's Bernoulli calculation code. Even as she pioneered programming, it seems bugs weren't part of her invention.
Ada Lovelace Day stands as a global tribute to the accomplishments of women in STEM fields—science, technology, engineering, and mathematics. This celebration falls on the middle Tuesday of its designated month.