Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

It seems that conventional wisdom suggests that good programmers are also good at math. Or that the two are somehow intrinsically linked. Many programming books I have read provide many examples that are solutions to math problems, or are somehow related to math as if these examples are what make sense to most people.

So the question I would like to float is: do you have to be good at math to be a good programmer?


locked by World Engineer Jul 20 '13 at 5:04

This question exists because it has historical significance, but it is not considered a good, on-topic question for this site, so please do not use it as evidence that you can ask similar questions here. This question and its answers are frozen and cannot be changed. More info: help center.

closed as primarily opinion-based by World Engineer Jul 20 '13 at 5:04

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise.If this question can be reworded to fit the rules in the help center, please edit the question.

@Mark Not necessarily. Learning a subject and liking it are two very different things. – Maxpm Mar 7 '11 at 8:09
Are you a king? Or conjoined twins? If no, I suggest you stick to "I" when referring to yourself. – drxzcl Mar 7 '11 at 9:57
@jk - you're correct most likely still think there's a good amount of art to programming ;p – Garet Claborn Sep 27 '11 at 4:44
I thought I never liked math. Later in life, I realized I just wasn't happy with the syntax. – MrFox Oct 31 '12 at 17:19
All of programmers use math all the time, they just don't realize it because it is so much different than math taught at school. Discreet math, lambda calculus, Boolean algebra, logic (!) are really advanced math concepts that we use every day. – rotman Nov 16 '12 at 18:41

67 Answers 67

up vote 82 down vote accepted

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.

On the flip side, If you want to become a low-level programmer or say create 3D graphics engines, mathematics will play a huge role.

I would like to add that I've seen some PhDs in math and physics write horrible code. These skills overlap to an extent but they are separate disciplines. – MrFox Oct 31 '12 at 17:32

It does depend on what you want to do. You to need know American high school math at least. Trig, logs, etc. If you can't solve the problem "Mark can mow the lawn in 2.63 hours and Mary can mow the lawn in 1.87 hours, how long will it take to mow the lawn if Mark and Mary work together?" I don't think you could do much programming.

Also, what is math? Is converting from decimal to binary to octal to hex math? You can find calculators to do that easily. I think a programmer should be able to convert 49 to base 7 rather quickly.


Not all maths are about crunching numbers. Anyone who can program is good at math relevant to programming. Remember: Mathematics is the study of patterns!


Mathematics is an abstract notation for modeling real world situations, and this is exactly what programming is.

If you can't visualize and figure out how to build an accurate working model of the world then you won't be a good programmer (or mathematician), and there's no getting around that. That said you could probably pound out some JavaScript and Bash and make a fine living at it without knowledge of advanced mathematics, but I assure you knowing math will only add to your ability to think abstractly and create better models.

Learning to be a good programmer is a ton of work, and I suggest that you simply consider learning mathematics to be a part of that workload because it can be the difference between being a fantastic programmer and merely being a competent one.


I think math would help. I have an undergraduate in applied math and a master's in MIS. I did get an MBA sequentially - but for the most part what has helped me stay in the IT field, most of which has been a developer (database and datatwarehouse programming), was the math.

I see computer programming as a "logical math" - but then again I see math as a language. As someone earlier stated, it helps in communicating complex ideas. The first programmers were actually mathematicians and engineers. A lot of people I know who are great programmers have an engineering degree.

If you want to be a programmer/analyst, math will help. It's the logic set necessary, and the discipline. I see relational databases as more of linear algebra anyway. There is a great paper on "Fast Monte Carlo Algorithms for Matrices: Approximating Matrix Multiplication". It is math-based.

Computer Science Majors are often part of the Mathematical Sciences Dept. at Universities. There is a reason for that.
Ultimately, there's not a "one size fits all" approach. I think they are a good compliment to one another - math and computers.
The most fundamental attribute for being a great computer programmer is being able to solve puzzles. There's always some bit of information missing, or information that is ambiguous.

Ask yourself this: "Would you rather have a 10,000 piece jigsaw puzzle with all the pieces there and no picture on the box to guide you, or would you rather have the same jigsaw puzzle with the picture on the box and have 10 pieces missing?"

I hope this helps !


For me, it was the other way around

because i liked programming, i was good at math, because for most concepts, i had a practical application, starting simple with logic (x and y or z), to simpler analysis ("ok, f(x) is a function. i know that, that even looks exactly like the functions in Pascal. go on"), to higher stuff (a mapping |R -> |R? ah, thats like a Dictionary with floats as keys and values).

I was often surprised, that math was not just not that hard, but instead provided me a much easier way of thinking about my programming problems than those clumsy, pragmatic languages i was coding in ever could.


Is it possible for people who don't like math to become a good programmer?

No, no-no, no, yes and no!

No, because often you need it.

(! (a | (! (b && c) || d) && (! e)))

Why doesn't it work?

foo ('a', 'b', 19, g(h))
bar ('c', 'd', 44) 

can it be rewritten in a more abstract way?

Is 968 ms more or less than 0.7 s? How many MB do you need, how many Ghz does the machine have, will a byte be enough - math is everyday part of the job. Sometimes explicitly and higher math.

Always implicitly lower math.

Math is a wide field, from calculating, to matrix, to geometry, logic, statistic, category theory, graph theory. So if you believe you're programming without using math - maybe you're wrong.

If you look at problems at the Project Euler page, you will find puzzles, where I don't have an idea, how math is used to solve it. (Not that I could solve them without math.) Note that the problem size is normally that big, that you can't solve them with brute force.

However - since I can't solve lot of them (about 2/3 by now), does it mean that I don't like math?

If you didn't study math, you will probably not know, where you can find math your daily life, including programming.

Even if you just specialised in moving GUI-components on the screen to look good, you're doing math in some way.


To be good at programming you can be good at math, however the two disciplines are completely unrelated to each other. The people with the highest aptitude for programming are people who are also gifted in the compositional arts such as music, painting, writing, film or theater directing or even choreography.

In the 1960's an insurance company did a study to find out who they should hire to train to program their mainframes (as computer science as a college major did not exist yet). They found that musicians and English teachers made the best programmers (in that order).

I've been working professionally as a software developer since 1982. And indeed the best programmers were those people who were good at music, in particular composition and arranging. The very worst programmers I ever worked with had PhD's in math. I've worked with two such people and they had zero knack for programming.

I was always good at math, but I'm also a musician, composer and writer. It is these latter talents that allow me to be a good programmer.


Well I was having lessons at a math teacher several months ago and I can say that if you have some mathematical knowledge you can benefit from it. For example: I was writing some javascript code and I had to simulate acceleration and deceleration. I heard about the fibonacci sequence from my math teacher so I was able to simulate this behavior easily with it. If I haven't had lessions however I don't know what I would have done. I think the point is obvious from this example.


I think it's a matter of how much math.

I can't imagine being a good programmer if you're not very comfortable with algebra. However, there is little need for math beyond this. I've never used anything beyond basic calculus and that only very rarely. I've used a moderate amount of trigonometry but that was almost entirely due to work on CAD/CAM stuff.

So, you've never used logic? Never used state machines, never learned any formal language, never programmed? It is all beyond algebra. Yes, calculus, linear algebra and so on are pretty much irrelevant in most areas. But the whole huge body of a discrete math is mandatory for programming (probably excluding the dreaded number theory). Probability theory and statistics are also extremely relevant to almost all of the programming. – SK-logic Mar 9 '11 at 10:00
but formally all this stuff is a math: – SK-logic Mar 9 '11 at 17:01

As aforementioned, math is thought to be important to be a good programmer. Does that mean, just learning formulas make you a good programmer?

Per my experience it is the ability to observe situations, and decide based on the observation that is needed: you see a case and pose a question about it. And look for answers to solve it. If you can break it into parts as means of solution it is the better. But it is still in the realm of logic.

The ability to think logically, and looking at problem with the attitude of solving it is very rare in society... in terms of percentage. Even between smart and intelligent people there are ones that perceive faster or slower.

Math happens to be a field that people don't understand and hold confusing. While the logic people using their reasoning "work with it" until they understand it. Therefore often the ones not having understood math, tend to associate the two fields with each other. While they are not.

Being able to observe and decide can make you also a good leader, a good cook, and so on. But it is eventually your decision and motivation that makes you a programmer.


No, as long as you are talking about math apptitude and not grades and include all subjects: logic, algegra, geometry, trig. I did much better in geometry than algebra because I think I understand things 'spacially' and my teacher did not require any memorization which is good because I have none. Probably why I like working with databases.

Also, it may have depended on your school system's math curriculum. Doing nothing but computations and memorization would have put me off.


Math is not one "thing". It's a large subject area with many components, a huge portion of which most programmers can an do forget in their professional careers (e.g. not every programmer creates statistical data mining, DSP, 3D, and aerodynamics modeling software, etc.)

Furthermore, one doesn't have to like math to be good at it, or good at just the portions required for most programming tasks.

I could easily see hiring an enthusiastic puzzle solver who never took calculus over someone who aced diffEQ but hated any kind of logic puzzle.


I have not found in practice that programmers need to be mathematically inclined to become great software developers.

Jeff Atwood - creator of this and all other stackexchange sites (the guy is a brilliant programmer).

Source -


Yes. Because most of the people who doesn't like math, think about theorical, formula math, instead of applied math to real world. Most of the programmers are not mathematicians, and still, use a lot of math, and it comes naturally.

For example, there are several math subcategories / branches, very specifical to programming. Automatons & Grammars & DFA, for programming language & compiler design. Relational Algebra & Relational Calculus for Databases. Boolean Algebra for conditions in programming.

In University, I watched that architects students didn't struggle with calculus, as others students did, because they applied all the time, to real world stuff. I see the same for math, for programmers.


"Like" and "be competent at" are entirely different things - so as long as you are properly numerate then I can't see a reason why you would have to like maths.

But lets be absolutely clear here - programming has a strong basis in maths and sooner or later almost any non-trivial development is going to involve calculations - you can't hide from this.

Any programming involves logic (basis in maths), most modern programming probably involves things (like SQL) that involve set theory (even if its not obvious) and if it doesn't then it may well be the case that you're off in realms (like games programming) that are even more explicitly maths based (rendering - maths, AI -> probability and randomness - maths...) and so it goes on.

The upshot of the above is that you have to be comfortable with numbers - you certainly have to get why "There are 10 types of people in the world, those who understand binary and those who don't" is funny. But you're probably excused "2 + 2 = 5... for very large values of 2".


You can look through endless source on GITHUB or programming books/tutorials without encountering any maths. A lot of web programming has scarcely got anything to do with algorithms, never mind maths. To be a computer scientist? Perhaps. Just to be a good programmer? No way.


No, no, and a side of no. Math courses help you to develop a method of thinking and problem solving that is useful as a programmer. The actual math however proves entirely unnecessary in most jobs in this industry.


The answer to this question is the same as if the question had been "Do we have to learn computer science to program?" Technically no, in that the ability to program doesn't require that you understand how caching works or how databases are fundamentally structured or even how the internet works. However, perhaps it limits what you're capable of programming. It's like thinking you can write poetry because you know english. Knowing how to formulate words to write poetry doesn't mean you can write poetry.

In this sense, you can program without knowing mathematics, though perhaps your inability to perform mathematics would undermine an essentially important skill of a programmer not only for not being able to do the mathematics but also for the ability to logically proof your code which comes only from years of programming experience or having performed proofs in mathematics, for instance.


Depends on the math. Not all math is created equal.

I'd say it's pretty hard to be good at programming if you don't understand some basic concepts in Discrete Mathematics like set theory and Boolean logic. Graph Theory and Networks has some pretty obvious applications.

That said, there's a lot of math that is useful to programmers only if it is useful to the problem domain of what you are building software for. It's fairly dependant on the field you are working for, however. I can say I honestly have never cracked a stats book for my work. I'd say Calculus, Statistics, Numerical Analysis, and Linear Algebra all fit into this collection.

And then there's a few caveats:

  • Math is, however, directly relevant to graduating college - I don't know of any school in the country that allows CS majors to pass without at least a year of math. And college diplomas are directly connected to the ease with which you can get a job programming. Also, good GPAs are similarly relevant.
  • I found math of many types EXTREMELY helpful when doing a grad course in Algorithms. Both the algorithms and the methods for analyzing them were extremely math dependant, and from a variety of mathematic topics. As the only math degree holder in the class, I had a serious leg up and the gang who had barely squeaked through math, and who managed to successfully wipe all undergrad math out of their heads had the worse time of it.

That said, I don't do that kind of analysis very often. There's too much chaos in the real world of integration and development to let me get that pure and mathematically perfect on the job.


Math knowledge is good for some applications (like gaming, artificial intelligence, computer graphics, etc), but math teach you something beyond just formulas or complex equations.

Learning math is like learning a new programming language. In fact, programming is applied math. When you learn a new language, you learn a lot of things that make you a better programmer. It is not different with math, but if you really master math, you will be a better programmer forever, even you don't use advanced math in your job.

The reason is simple: math teach you to see the world with other eyes. It teaches you to solve problems with different approaches without necessarily programming. This new way to think certainly leds you to a better way to do your job.

Programming is an art. Math is an art. If you combine both of them you will be a better artist.


Maths is the ante-room of programming.

Being able to work with layers upon layers of abstraction, models, "objectification" of functions, transformations and temporal concepts, maths is the perfect training ground for all that.

It is possible to develop the right mindset to programming without maths but it's a lot harder.

However, specialist areas aside, only understanding maths is important, knowing the name of everything and how a given theorem can be proved isn't. So even if you have good marks in maths because you learned it all without really understanding, you will still struggle with programming.


I use to say "No, you don't (necessarily) need to be strong in maths to program".
And I immediately mitigate the sentence..

Pro: As a programmer, I rarely do more math that incrementing variables, doing some operations you do on a desk calculator (+ - * /), sometime go as far as doing a modulus and a percentage...

Con: Actually, you have to apply some branches of math, particularly logic... Some other maths can be useful: concepts around floating point numbers, Boole algebra, theory of sets, etc.
And of course, if you do some graphics, you better know some trigonometry, sometime integration theory, probability, etc.
If you go into functional programming (a domain I discover), you might find it strongly mathematically oriented, with algebraic types, and other algebra theory which can be simple or go to some difficult theoretical highs...


To be honest, I was a horrible math student in school. Algebra was completely beyond me at the time, and I don't think I ever got higher than a D in it.

However, a few years later, after having worked as a professional software developer, I went back to college and took a course in algebra. To my amazement, it was the easiest class I had, and I got an A in it.

Truth was, programming taught me algebra, because virtually everything is just an algebraic expression.

So no, you don't need it to start. It helps, but it isn't required. The beautiful thing about software development as a means to teach math is that the compiler, debugger, and executing program are wonderful ways to verify that you've got the answer correct. In this regard, debugging particularly is a huge boon to learning, because you can step through the code and watch each step of your algorithm's evaluation.


From my experience I can tell that there is math and there is other math. If we take a birds eye view at math from the scientific point of view, we will discover that dealing with math requires a high potential of thinking "a logical" way - while following strict rules. This is diffenrent to some other siences - lets say at Arts. So this logical apporach is absolutley mandatory to be a programmer.
Basicly the way you think while programming is very simular to the way you think while dealing with math.
Further there are lots of problems to be solved via math when programming, but this is what I tend to call the "real world math". You can find some examples in the posts above. Also writing a 3D engine is quite complex, the math behind isn't that complex at all. It just requires some structured thinking.
"The other math" is the one you deal with when you (e.g.) study math. There you don't do real world stuff anymore, you focus on more abstact tasks like defining or proving mathematic rules. That materia becomes very complex within a short period of time, but it is not required for your job as programmer.
In other words: you need a basic understanding of math and you should be able to think a structured way, but you do not need "high level" math to be a (good) programmer.


I just finished an intro course to discrete math, and I found that I already knew almost everything about predicate logic thanks to programming; all that was new was the syntax--it was basically just working with booleans.

In short: perhaps you do not have to learn math explicitly, but just by being a programmer you have probably learned some math without realizing. That is, by being a "good programmer", you are also really being a mathematician (to some extent).

The Curry-Howard Correspondence illustrates what I mean: basically, it states that mathematical proofs and certain computer programs are "isomorphic", that is, they are different ways of writing the same thing. Of course, it is actually more complex than this, but I'm not a mathematician, so this is the best explanation I can give. Hopefully it isn't too far off the mark.

In summary, not only do many fields in CS and programming involve a lot of math, but even basic programming ideas (e.g. booleans) are basically math in disguise.


It depends on what you're programming. A 3D game engine, for example, would be extremely difficult (if not impossible) to pull off with any degree of coherency without knowledge of the appropriate mathematical concepts.


Math and programming are very closely related as math is really the universal language between humans and computers. You do not need to know a lot of math for high level programming as a lot of that is behind the scenes, but it will aid in comprehension for a lot of more advanced programming concepts. If you plan to do more low level programming (systems or device programming), then you will need to know a lot more math.

+1. You'll also need math if you want to do "high level" things like signal processing, machine learning, computer vision, 3D rendering, physics simulations, animations, computational geometry, cryptography and probably many other fields I can't think of right now. – nikie Mar 7 '11 at 9:17
@nikie: Yeah, but that's applied mathematics. Huge difference. ^^ – gablin Mar 7 '11 at 15:21

You have to either learn math, or create your own. Either way it is important to be good at it in some form or another.

As long as you can work with values and understand what they are doing, why and what you can make them do, then traditional mathematics may not always be necessary. Occasionally it even gets in the way.

There are alternative ways to visualize a byte's value other than numbers, but they are most definitely the most thought after method. It would be feasible to write a program thinking of all values as colors for instance.

Today's programing derives much of it's value from being able to represent 1s and 0s as different types of data. Even though really those 1s and 0s aren't numbers at all, but electrical wavelength changes, math isn't so much at play as physics,... however,... it is very important in understanding a great great deal of what other programmers say and code.

Still it would be possible to be a good programmer without math, however difficult.

Thinking of all values as colors almost makes MORE sense. When you go too far off one end of the spectrum, you wind up on the opposite end... – Maxpm Mar 7 '11 at 8:10

First in trying to come up with a meaningful answer to that question it should first be acknowledged that mathematics and computer science as subjects are both large and diverse in terms of the concepts that they cover. One common thread that unites the two are that they both deal with abstract concepts. An ability to deal with abstract concepts would imply that some areas of both Mathematics and Computer Science should be accessible to you. Put another way, a situation where someone is able to write programs but not solve any maths problem or where someone can solve maths problems but is unable to grasp any aspects of programming both seem implausible. A fairly basic abstract concept that human brains are generally able to comprehend and one that a fairly major component of both subject is numbers. Above and beyond your ability to understand numbers. the extent of your natural talent for wrestling with abstract concepts with determine the complexity and variety of the mathematics or algorithms you are able to understand.

Beyond natural talent however both solving maths problems and programming both require enormous amounts of dedication, practice and study to become proficient. So if you have an agile brain and commitment you probably have the potential to be good at either. However having the potential to be good at something and actually being good at something are usually determine by confidence which is a different beast entirely.

Plenty of good programmers get nervous when confronted with too many equations. This is usually more due to a combination of not having invested the same amount of time and previous bad experiences which leads to a lack of confidence rather than an inability to understand them.


Not the answer you're looking for? Browse other questions tagged or ask your own question.