TITLE: Narayana and Fermat's Factorization Method
QUESTION [14 upvotes]: In some notes of mine I have found a comment according to which the Indian mathematician Narayana Pandit (14th century) found the prime factors of $1161$ by writing it in the form $1161 = 35^2-8^2$. Unfortunately I can't find the source of this piece of information. Any help is appreciated.

REPLY [2 votes]: Unfortunately, sources on the history of Indian mathematics are somewhat hard to find on the internet (and even in libraries). Fortunately, this particular question can be answered.
Three scholars of the history of Indian mathematics taught a course called “Mathematics in India - From Vedic Period to Modern Times”, which is available online: see course outline, syllabus, lecture notes, actual course, YouTube playlist. This particular topic (Nārāyaṇa Paṇḍita's treatment of factorization) is covered in Lecture 27 by M. D. Srinivas, starting at slide 12 or from 15:25 to 20:10 in the video.
Apparently this is the first (known) book in Indian mathematics that discusses factorization (as late as c. 1356), but the treatment here is already nontrivial and contains what is known as Fermat's method (17th century). After stating the usual method of checking whether the successive acchedyas $2$, $3$, $5$, $7$ etc divide the number (literally, “acchedhya” means “indivisible” or “irreducible”), Nārāyaṇa says: given a non-square number $N$,

writing $N = a^2 + r$, if it so happens that $2a + 1 - r$ is a square (say $b^2$), then our work is done: $N = (a + 1 + b)(a + 1 - b)$. [apada-pradasya rāśeḥ padam āsannaṃ dvi-saṅguṇaṃ saikam /
mūlāvaśeṣa-hīnaṃ vargaś cet kṣepakaś ca kriti-siddhau //]
Else, if it ($2a + 1 - r$) is not a square, add $(2a + 3)$ and so on, and keep doing this [numbers increasing in arithmetic sequence, i.e. successive odd numbers] until you get a square. That is, if $(2a + 1) + (2a + 3) + \dots + (2a + 2k - 1) - r$ is a square (say $b^2$), then $N = (a + k + b)(a + k - b)$. [vargo na bhavet pūrvāsannapadaṃ dvi-guṇitaṃ tri-saṃyuktam /
adyād uttara-vṛddhyā tāvad yavad bhaved vargaḥ //]

After having stated this rule, he works out two examples: $N = 1161$ and $N = 1001$ — of course both are easy to factorize directly (using the straightforward method he mentioned earlier), but I imagine he chose these examples because they illustrate the two cases: in the case of $1161$, already $2a + 1 - r$ is a square, and in the case of $1001$, we have to add as many as $14$ terms before we get a square.

More references: 

The (Sanskrit) text of Nārāyaṇa's work (Gaṇita-kaumudī, c. 1356) was first edited and printed by Padmakar Dvivedi, son of Sudhakar Dvivedi in two volumes: 1936 (Volume 1) and 1942 (Volume 2).

It took me a while to locate it, but this particular section on factorization (part of vyavahāra (Chapter) 11) is on page 246.

An English translation of the work, with notes, was published by Paramanand Singh in successive issues of the journal Gaṇita Bhāratī: 20 (1998), pp. 25–82; 21 (1999), pp. 10–73; 22 (2000), pp. 19–85; 23 (2001), pp. 18–82; 24 (2002), pp. 34–98.
Some (more easily available) (brief) references to Nārāyaṇa's Gaṇita-kaumudī (focusing more on combinatorics) can be found in The Art of Computer Programming by D. E. Knuth (Volume 4A, section 7.2.1.7, pp. 499–500, earlier published as Fascicle 4B, draft version online), in the book Combinatorics: Ancient and Modern (OUP 2003), etc.