How to cite an answer in StackExchange?
There is a link at the bottom that provides a citation in bibtex or amsrefs format;



Clicking on this particular link the bibtex citation generated is;


  @MISC {58756,
      TITLE = {Unique ways to keep N balls into K Boxes?},
      AUTHOR = {Gjergji Zaimi (https://math.stackexchange.com/users/14274/gjergji-zaimi)},
      HOWPUBLISHED = {Mathematics Stack Exchange},
      NOTE = {URL:https://math.stackexchange.com/q/58756 (version: 2011-08-21)},
      EPRINT = {https://math.stackexchange.com/q/58756},
      URL = {https://math.stackexchange.com/q/58756}
  }


You could put that in your .bib file. From that point, it really depends how the rest of your citations are being formated. You might get something like;



That seems like a pretty standardised way to do it.