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

No. You do need to be good at logic though, which isn't exactly the same thing. Me, I'm great with the logic, but the numbers generally throw me for a loop. I can work it out, but it takes me longer to do the mathy bits.


The short answer is no. I think it's a bit of a myth but it's propogated because maths problems are usually well suited to being solved by computers.

So in uni/college, people will get maths problems that they need to solve in compsci subjects but what you will usually find is that the maths is actually harder to solve than the code that is needed to implement the solution.

Once you get into the real world, you'll increasingly find that the problems are largely solved for you, your job will just be to implement them in code.


It somewhat depends on what exactly you are doing, though it definitely can't hurt.

For example, someone who majored in Computer Science has got to go through a lot of math to get their degree. CS generally focuses a lot on algorithms and their correctness, proven through high-level math-style proofs. Many Universitie's CS programs are so close to their math program that a double major is only a few courses away. Even as a Software Engineering major, myself, I was 2 courses away from a Math minor.

However, that being said, a lot of the proofs, data structures, search methods, and algorithm correctness stuff that I learned hasn't really been put to direct use since I finished school. But it would be hard for me to say that it didn't at least give me a good foundation and better understanding of what I do at a low level.

Because no matter how you look at it, at the lowest level, everything you are doing boils down to math.


Depends. Enterprise CRUD (Create, Read, Update Delete) apps usually don't need exceptional math skill. On the other hand if you are designing algorithms a background in math will help and in many cases be necessary.


I think it obviously depends on what sort of programming you're talking about.

If you want to write the rendering engine for a video game, you're going to need stellar math ability to have any hope. If you want to develop data structures and sorting algorithms, math is very important.

If you want to develop websites and line of business applications, complex math really does not come into play that often (excluding the problem domain).

Either way, I think the most important thing is that it's never too late to learn.



Much like most science disciplines, having a good understanding of maths concepts is going to be helpful, particularly when evaluating things like efficiency. But for most programming tasks your maths ability is only relevant if the problem you're solving is related to maths.

Computers are excellent at doing mathematics, so it makes sense that early computers were used extensively to do the 'grunt work' associated with a lot of complex maths work. A lot of software still does solve complex maths problems, in that case being good at maths will help you write a better program, but it's not what makes you a good programmer.


Usually, not in the sense that you need to know, say, calculus or trig equations to do most work. If you're doing heavy graphics/game programming, then yes. A famous math hack for Quake is a good example of this. However, the thinking that you have to get into while dealing with higher-level math certainly is applicable to programming; with programming, you are developing your own logic structure, your own functions, your own "proofs."

The only time I've run across math in my job (internal enterprise workflow and apps) is when I do some reporting apps that require knowledge of statistics, but that's only because it was directly applicable to requirements.


You don't have to be good at math. However, you have to be good at logic, and problem solving. However people who are good at logic and problem solving are usually good at math also. I would say that it really depends on the type of math. You can be terrible at calculus (like me), and still be a good programmer (like me). But if you have trouble with Discrete Math and Set Theory, you would probably find a lot of aspects of programming quite hard.

Are you sure that you are a good programer? :) – Russell Mar 27 '12 at 13:18

Ditto Tim. There are some areas, like 3D graphics, where you'll want to understand, for example, physics, but for the most part you can get by with just arithmetic and some simple algebra.


This is a very hard question to answer and will likely stir up a lot of debate.

One of the reasons why this question is so hard is that it partly depends upon what type of work you are doing. There is not a lot of math involved with most business applications, so you can get by with a solid understanding of algebra and business math. However, more advanced applications call for more advanced math and you start needing a solid understanding of calculus, linear algebra, and the like.

However, that is just one part of the equation in that you still need a certain degree of mathematics for just the practice of programming itself. It goes without saying that you need to be comfortable with logic to just be able to write a basic program as well as basic algebra. Looking a bit beyond just getting a basic program working though you need to have an understanding of certain aspects of discrete mathematics to be able to make determination as to what makes for a good algorithm to use for a given problem.

To get back to the heart of the question though. I personally don't think you need to be a mathematician to be a good programmer; however, I do think that you need to be comfortable with math to be able to be a good generalist programmer.


I would say not necessarily. Certain programming disciplines (crypto, graphics, physics engines etc) would definitely have a clear advantage for the mathematically inclined, but I don't think a good understanding of differential equations would be particularly useful for web programming for instance.

Boolean logic is probably a requirement to be a good programmer, but it wouldn't surprise me if a lot of people who didn't achieve good marks in high school maths turn out to be good at programming.


Not maths as such, but arithmetic comes into play a lot.

Unless the application you're writing is heavily mathsey, then you don't need it to be a good programmer. If you're just starting out and want to get into games or graphics programming, then that can often be quite maths oriented.


I would say you definitely don't need to be good at math to be a good programmer.

My first job as a programmer was doing 3D graphics for B-52 and Cruise Missile mission planning. It was a math intensive application, but I really only needed access to people that were good/great in math. I didn't need to know the formula for computing great circle distances between two points. I did need to know how to convert the formula so that it worked in a programming language. The same with flight simulation. Boeing did all the math we just had to apply it.

That experience also helped me get a sense of who would be a good programmer and who wouldn't. The job had pilots and navigators taking a tour of duty as programmers and to help the programmers understand the needs of the mission. You could usually tell within a few weeks what pilots and navigators would be good at it. Math majors usually took to programming right away.

So I would say being good at math makes it more likely you will be good at programming, but I know a lot of good programmers that aren't so good at math.


Almost everybody has answered: "do you need to know math to be a good programmer?" The correct answer to this is: "No, not really, but it helps," as many have already said.

But my interpretation of the question is "is there a strong correlation between mathematical aptitude and programming aptitude?" The correct answer to this is: "Yes, there is." If you struggle through algebra, geometry, and calculus, then you probably aren't very good at dealing with abstractions and/or thinking logically. If you're bad at math, you probably won't ever be a great programmer. (Not that you shouldn't try.)


I disagree fairly strongly with Daniel (to a point). To be a capable with the programming languages, api's and tools that you use, it strong math skills aren't necessarily required. However, if your goal is to go beyond the level of coding to other people's specifications being able to apply math and more complex algorithms to a problem (I consider these to be very similar) will take you a long way toward that goal.

Now for the why. In my experience, it's usually not hard to come up with programming solutions to many propblems that meet the requirement of producing the required output and keeping to a few restrictions. Where the math will really help you is when you have to take an existing solution and make drastic improvements to it. For example, if you need to write you own text comparison code, it isn't hard to use the search text to generate a simple regex to account for some spelling differences, but if you want to be able to emulate the behavior of Google Suggest, you need to understand algorithms like Soundex, Levenstein Distance and others. For a more mathamatical problem, consider a cache for keeping commonly used objects in memory instead of hitting the DB every time. How can you generate hash values in such a way that two objects with trivial differences have the same hash value?

At the end of the day though, the type and amount of math you need really depends on the field you're in. If you working with computer graphics, strong calculus and algebra skills are pretty important, but developers of financial software can probably get manage without. On the other hand, in any application where you have to deal with floating point arithmetic, having a strong understanding of number theory is a necessity, otherwise you'll constantly be faced with running totals that no longer add up correctly (due to rounding, truncation, and number representation issues).


Yes, definitely.

Even run of the mill business programing requires some skill at math.

Run of the mill business programing requires database skills. Being a good database programmer requires an understanding of how databases work, and what the algorithms are that the query processor uses when it translates your queries. Without an understanding of limits and derivatives (or even the basic understanding that the line y = x intersects the line y = x^2 twice), it is not feasible to accurately compare a hash-match inner join query plan vs a nested loop join query plan.

Also, a good programmer can work in just about any domain, provided that they study up a bit: games, simulation, embedded development, compilers, operating systems, web stuff, databases, etc. Being able to do all those things (or more accurately being able to quickly learn how to do all those things) requires a decent amount of mathematics background.

I'd say that one should have had some experience at some point in time with the following:

  1. 3 Semesters of Calc
  2. Diff Eq
  3. Linear Algebra
  4. Modern Algebra
  5. Basic probability,counting, and statistics

I'm going against the grain and saying yes, you need a math mindset. Most people think of math as doing arithmetic or memorizing arcane formulas. This is like asking if you need perfect spelling or an extraordinary vocabulary to be a good writer.

Writing is about communication, and math/programming is about the process of clear, logical thinking (in a way that you can't make mistakes; the equation doesn't balance, or the program doesn't compile). Specifically, that logical thinking manifests in:

  • Ability to estimate / understand differences between numbers: O(n^2) vs O(lg(n)), intuitive sense of KB vs MB vs GB, how slow disk is compared to RAM. If you don't realize how tiny a KB is compared to a GB you'll be wasting time optimizing things that don't matter.
  • Functions / functional programming (is it any coincidence that the equation f(x) = x^2 is so similar to how you'd write that method? The words "algorithm" and "function" were around in the math world far before the first computer was born :-))
  • Basic algebra to create & reorder your own equations, take averages, basic stats

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".

Math major vs math mindset: it's like the difference between knowing all of the physics formulas, and being able to accurately bounce a rubber ball off of a backboard 20 yards away! – TehShrike Oct 17 '11 at 4:40
I'll add that many good programmers know how to play chess or go :-) – xanatos Oct 17 '11 at 5:11
An awful lot of computer code is basically algebra although you're setting it up for the computer rather than solving it yourself. If you're not totally at home with algebra how can you expect to do a decent job of this? – Loren Pechtel Jan 17 '12 at 2:21
Mathematical thinking is the key to programming. I am adding my vote to emphasize exactly that. – Gus Jan 20 '12 at 6:37
+1 Math is vital in the understanding of programming languages because it is the basis of our craft. Most programming language constructs that we use on a day to day basis are lifted from math disciplines such as lambda calculus. – MattDavey Jan 20 '12 at 9:28

I found an interesting article and ensuing discussion regarding this question:

Slash7: Got Math?


The fundamental concept of maths is the following, devising, understanding, implementation, and use of algorithms. If you cannot do maths then it is because you cannot do these things, and if you cannot do these things then you cannot be an effective programmer.

Common programming tasks might not need any specific mathematical knowledge (e.g. you probably won't need vector algebra and calculus unless you're doing tasks like 3D graphics or physics simulations, for example), but the underlying skillsets are identical, and lack of ability in one domain will be matched by a corresponding lack of ability in the other domain.


I say this as someone who is neither great at math nor necessarily a remarkable programmer, so perhaps you can take my opinion with a little grain of salt.

When you know continuous and/or discrete math a bit better, you'll find that problems you encounter benefit from that knowledge. Similarly, when you at least understand how algorithms like breadth first search work, you'll discover applications for that more readily than before you understood it. Some problems that seem intractable when you only know about simple data structures like arrays and linked lists suddenly seem relatively simple when you understand a little bit about graph problems.

The point is, almost all kinds of knowledge will make you a better programmer.

I'm not sure that the inverse is true: that you MUST be good at math to be a good programmer. But I suspect that the difference between good and great may be a question of math skills.

Steve Yegge's blog has at least one argument in favor of shoring up one's math skills. It's an interesting read.

Basically, almost any kind of domain-specific expertise can be useful as a programmer. I probably wouldn't be in this industry had it not been for my German and Japanese skills; it was a question of right place, right time, right foundation. I suspect knowing even trivia-level details about biology (ant colony optimization?) can open your eyes to more ways of solving problems.


Pretty much repeating what everyone else has said. The more graphics you are doing the more math you will need. 3D stuff gets kinda hairy with the trig and matrix stuff, but like everything else, you learn the idioms and you're good to go


Math is more than just formulas. Understanding some mathematical principles about set theory is very useful to grasping complex concepts on type systems, as is understanding complexity a paramount to efficient data structure usages.

Graph theory is also extremely useful, as many programming problems can be modelled by a graph. I was very astonished, as I was developing a business application, to find out that the shortest path theorems were providing an elegant solution to a thorny problem that I had!


Short answer: It depends on what kind of programming you're doing.

Longer answer: If you mean specific mathematics courses that you do, then it very much depends on what kind of programming you're doing. Some kinds will be useful to all programmers (see Concrete Mathematics by Graham, Knuth and Patashnik, for example), whereas some can get by without using, say complex analysis (which I have used in programming).

More generally, the kind of logical thinking that mathematics needs, particularly in finding flaws in bogus proofs (e.g. that 1=0) hones the kind of thinking needed in debugging.

Personal suggestions:


  • Calculus - general purpose. More advanced courses in it may be useful (e.g. complex analysis is used in electronic engineering).
  • Statistics - general use, have used it personally in my career.
  • Logic - converting logical expressions into equivalent but simpler expressions, checking the validity/nonvalidity of a proof.
  • Computability theory - see proof of Halting Problem being unsolvable for Turing machines - you may find yourself trying to solve something equivalent to it some day, then rewrite the code to solve a possible task, depending on the domain.

I am pretty bad at general math. However I am very very good at logic and problem solving.

It helps that I started programming BASIC when I was like age 10 though.

I consider myself to be a "good" programmer. I know however that I will probably never write a 3D engine or face recognition algorithm or anything like it. And that is the key. Everyone has limitations. I know there are certain areas in software that I will never be able to go. But likewise those people that are exceptionally good at math aren't always the best software engineers/architects either.

Just last week we interviewed a guy that could probably write you a face recog' algorithm in the space of a week. However he knew nothing about design patterns or architecture. Nor did he display any interest in them at all.

So no. I don't think you need to be "good" at math in order to be a "good" developer. There are many different types of developer.


If you are not very good at math then your answer will undoubtedly be "no, math skills are not required". If you are one of the small percentage of people that actually know math and use it everyday, then you realize how valuable your math skills are and how they enable you to quickly develop routines. You will not spend countless hours debugging using trial and error methods. Your functions and classes will be "reduced" allowing for more complex functionality. Given enough time and motivation, anyone can program. Will the code that person writes be any good?? I guess if it works, right?

Bottom line. A programmer with good math skills will be a far better programmer than the one who lacks. They will be much more productive and will save the company oodles of money in development costs, both in the present and future when the application needs to be expanded upon.

The most basic program is an exercise in Algebra. If a programmer does not recognize this, the result is code that is not reusable. You get lots of repetitive "almost the same" code. Another word for this type of programming is "non-scalable"!


Yes, of course. They are entirely different.

I know many good programmers, when I say good they know design patterns have degrees from good universities and now work in commerce (finance sector). And have a number of large released successful products. They know A-level maths I would say (a-level is exam you take when you are 18 in uk, generally).

It may be somewhat unusual to be a good programmer and not be interested maths. But I think a lot of people are prejudice in thinking one must like/be good at both. They are not dependent on one another.

How can they be "different" if programming (a coding part of it) is just a branch of math and nothing more?!? – SK-logic Mar 8 '11 at 12:58

A good one? Very unlikely. Most design patterns have at least some basis in mathematical concepts. Things that are essential to programming, like variables, loops, procedures, and objects, are analogues to concepts in mathematical fields like algebra, calculus, and set theory.

Consider also that computer science is a subset of mathematics: algorithms and formal logic, upon which all programming is based, are fundamentally mathematics.

If you hate math, you're going to hate programming.


Maybe, most programming jobs are about plumbing stuff together. You could be a good programmer in that field.

Hmm, on one hand I agree, but on the other hand I think:"Is a guy who only plumbs stuff together a good programmer? (even though he plumbs them together very well)" I don't know really. It all depends on the definition of good programmer. – Matthijs Wessels Sep 17 '10 at 9:06

I think it is possible. I personally know someone who sucks at math and as I know is a pretty good programmer.

However IMHO programming has a relation to discrete math and being good at that does help you in your programming.

But being able to integrate and differentiate and that kind of math is not really relevant, while that is where most people have problems with math.

Integration/Differentiation is Calculus, which is only one very small subset of math. The rest of mathematics still apply to programming. – user8 Sep 17 '10 at 8:39
Yea, that's what I meant. I feel that Calculus (and maybe Geometry) is where most people have problems with maths. The guy I know who is a good programmer but says he's bad at maths is most likely thinking about stuff like Calculus. While maybe the fact that he is good at programming might even imply that he is good at Logic and thus maths without even realising it. – Matthijs Wessels Sep 17 '10 at 9:02

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