# The Two Types of Programmers: Logician and Mathematician

Jul 14, 2024 • 1136 words

Oftentimes, it’s said that being a programmer means you have to be good at maths because the original term of “computer” is for people doing mathematical calculation. If you were to create a program that are basically a machine executing a bunch of calculation, you should be good at mathematics.. right?

Well this topic is something that has been hotly debated on some platform, and mostly everyone has been thinking about it. Whether you should learn some advanced math just to get better at programming. But I would like to think that it’s not always the case. Learning mathematics can give you benefits, such as having better brain functions and able to solve a problem with better algorithms. I thought about this back in around 2021. I was still an unemployed person back then, I was grinding Codewars since I would like to start making money as a programmer. Yet, on Codewars I encountered people answering with different kind of “style”. Well I don’t think the term “style” fits here, but let’s use that for now.

## The Case of a Simple Problem

Let’s open up this kata on Codewars: https://www.codewars.com/kata/514b92a657cdc65150000006/go. A simple task:

If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.

Finish the solution so that it returns the sum of all the multiples of 3 or 5 below the number passed in.

This is a very simple thing to do, right? We’d just do a modulus of 3 and 5 like FizzBuzz problem, if the number suffice the rule, we should sum it with the previous sum.

One solution that’s easily would be on top of your mind after reading that might be something like:

```
func Multiple3And5(n int) int {
var sum = 0
for i := 1; i < n; i++ {
if (i % 3 == 0) || (i % 5 == 0) {
sum += i
}
}
return sum;
}
```

But also on Codewars, there is a top ranking answer like so:

```
func Multiple3And5(number int) int {
n3 := (number-1) / 3
n5 := (number-1) / 5
n15 := (number-1) / 15
return (3 * n3 * (n3+1) + 5 * n5 * (n5+1) - 15 * n15 * (n15+1)) / 2
}
```

It got the result right. It even produces better performance of O(1) instead of O(n) like the previous solution. So, what’s happening here? What kind of things do you need to know in order to make it happen?

The formula is called “aritmethic series”. An *arithmetic series* is the sum of the terms of an *arithmetic sequence*. Whereas, an *arithmetic sequence* is a sequence where the difference **d** between successive terms is constant. You can find more about that here: https://math.libretexts.org/Bookshelves/Algebra/Advanced_Algebra/09%3A_Sequences_Series_and_the_Binomial_Theorem/9.02%3A_Arithmetic_Sequences_and_Series.

## Should we really learn more mathematics?

Okay, now we know what that is, but now, I hope the same question would pop up on our head: **If solving that problem with mathematical formula makes it better performance-wise, should we learn more mathematics to really improve our program then?**

For this question, there are of course, different answers, but I guess the consensus is that “No, not really. But, math helps.”. Let’s see some of the answers there are online.

I think it depends on what type of programming you want to do. As far as being a programmer in the business world goes, I would say that the answer is no. You can become a great programmer without knowing advanced mathematics. When you do end up having to deal with math, the formulas are usually defined in the business requirements so it only becomes a matter of implementing them in code.

By Daniel Auger from Software Engineering Stack Exchange. CC BY-SA 2.5.

So, I’ll say you need a math mindset, being able to construct & manipulate mental models of what your program is doing, rather than a collection of facts & theorems. Certain fields like graphics or databases will have certain facts you need also, but to me that’s not the essence of being “good at math”.

By kurious from Software Engineering Stack Exchange. CC BY-SA 2.5.

To answer your question as it was posed I would have to say, “No, mathematics is not necessary for programming”. However, as other people have suggested in this thread, I believe there is a correlation between understanding mathematics and being able to “think algorithmically”. That is, to be able to think abstractly about quantity, processes, relationships and proof.

From Stack Overflow. CC BY-SA 3.0.

While advanced mathematics may not be required for programming (unless you are programming advanced mathematics capability) the thought process of programming and mathematics are very similar. You begin with a base of known things (axioms, previously proven theories) and try to get to someplace new. […] The ability to translate from concrete to abstract also links the two fields.

By Jarret Meyer from Stack Overflow. CC BY-SA 3.0.

## The Case of The Two Types

Let’s get back to the initial discussion: there are two types of programmers. Those of logicians, and those of mathematicians. Logicians think more of creating solutions set that have much more general logical forms. Whereas mathematicians think more of creating solutions that lifted by axioms, proven set of theories. You can say that perhaps, logicians are the ones who will come up with simpler solution, and mathematicians are the one who will come up with optimized solution. It’s not entirely wrong, but I’d rather say that logicians are the one who think more in a semantics way. It’s about creating a solution which more deceptive (tending or having power to cause someone to accept as true or valid what is false or invalid, see Merriam-Webster), rather than actually focusing on validity by using proofs (see Mathematical logic).

I’m not saying a programmer with the type of a mathematician would always produce solution based on mathematical concepts. But, it’s regarding their way of thinking. Being either one of it (logician or mathematician) is fine. Most of the time, there are more than one solution to a problem. Your programming buddy might as well produce a different solution from you, and that’s what makes programming beautiful.

It’s kind of vague to leave everything as is here, but I’d also like to say that, you don’t need to learn advanced mathematics just to be a better programmer. You just have to train more.