Writing computer code in a mathematics paper. I have some computer computations (using GAP) in my research which I would like to write in the paper. How should I go about it? 
Should I include the full working code or just the major algorithms? If just the algorithms, then how should I write them? 
Can you suggest some existing math articles (preferably published in reputed journals) which have done this?
 A: It depends on the journal which you are going to choose for the submission. Some journals may also publish supplementary files with the code, such as, for example, LMS Journal of Computation and Mathematics. You may also publish the code yourself, e.g. using Run My Code. Services like GitHub or BitBucket are also fine, but you should be explicit about versioning your software, so that any reader who would be interested in reproducing your experiment would be able to get that version of the code which was used in a paper. Ideally, you code could have a DOI like a paper, and that URL will point to precisely that version - there is now an ongoing project "code as a research object" addressing this need, you may read more here and then here).
If you think that your code could be organised in the form of a GAP package since it involves a significant amount of programming and may be interested to other users, then you could also go this way and then refer to the package it from your paper. Of course, one can then just made the package available from its homepage, but I'd recommend to submit it for the redistribution with GAP. In this case it will be included in GAP regression testing and this will reduce the chance that it will be broken in the future. There is a GAP package called Example which provides an Example/Template of a GAP Package and Guidelines for Package Authors. You're welcome to contact GAP Support to discuss an idea of a GAP package in case you have one (a smaller piece of code perhaps may be incorporated in an existing package if that is relevant/appropriate - BTW, there seems to be a package developed in Ghent, listed here). 
Anyhow, this may still constitute a difficulty for the reader who would be interesting in reproducing your experiment. Which version of GAP shall be used, which versions of GAP packages; are there packages that should be compiled; are there non-trivial dependencies on external libraries? Even if configuring all of these is straightforward, this may take some time. However, one could create a virtual machine providing a recomputable experiment, and I suggest to get in touch with the Recomputation.org project if you would be interested in this. This virtual machine may be created early enough to accompany your paper submission, so the reviewer may be able to re-run the experiment in case he/she will be interested.
Finally, there are also journals where you may publish paper primarily focused on the mathematical software aspects, see, for example, Journal of Software for Algebra and Geometry or this list published by the UK Software Sustainability Institute.
A: I would suggest just the algorithm should be fine. You can post your working source code online on site like GitHub or BitBucket or SourceForge.
To typeset algorithms in $\LaTeX$, you should consider using one of the following packages: (i) algorithmic, (ii) algorithm2e or (iii) algorithmicx.
You can also try literate programming to explain the program as you go through your article.
