Skip to content

Instantly share code, notes, and snippets.

View zlw5009's full-sized avatar

Zach Williams zlw5009

  • Little Rock, Arkansas
View GitHub Profile
@zlw5009
zlw5009 / recursion_using_euclids_algorithm.md
Last active February 11, 2023 09:37
Finding the GCD in JS using Euclid's Algorithm

Where Javascript and Recursion Meet Euclid's Algorithm

I'll be explaining recursion utilizing Euclid's Algorithm for finding the greatest common denominator when both variables are greater than zero.

What is Recursion?

Recursion is a mathematical procedure that utilizes a procedure or definition within itself to develop a solution. Now if you're anything like me, reading that statement just appears as a bunch of wordplay. Truth is, recursion is a difficult topic to understand during your initial encounter with it but as time progresses and your experience using recursion grows, you'll grasp the concept with ease and be able to implement recursive solutions into your own code.

Before we start, it's worth mentioning that there are several great articles discussing recursion and the fundamentals of the topic. In writing this, I'm not only providing a tutorial on how recursion works to find the GCD but also assisting myself in completely grasping the concept. I do recommend working through a problem

@zlw5009
zlw5009 / blocks_foundations.md
Last active June 27, 2021 06:59
An article on Ruby Blocks and Procs

Building a Foundation with &blocks

What is a Block?

Blocks... What are they anyway? You've probably used them without even realizing it and most certainly have seen them, but do you know what they are?

If we wanted to take a simplistic approach at defining a block we could say:

A block is a chunk of code contained within the do..end or { curly braces } syntax that is to be executed at some point in time.

With that being said, if you've ever used the Enumerable#map or Enumerable#each method, you've probably used a block. Lets take a look at two different types of blocks before we go into more detail about what a block really is.