From 00a886ea0c076f0d8913f7d93744506da6db3d1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20Axel=20S=C3=B8gaard?= Date: Tue, 16 Oct 2012 16:53:06 +0200 Subject: [PATCH] Documentation on polygonal numbers --- .../math/scribblings/math-number-theory.scrbl | 48 ++++++++++++++++++- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/collects/math/scribblings/math-number-theory.scrbl b/collects/math/scribblings/math-number-theory.scrbl index 763bd019c7..778c7f82ae 100644 --- a/collects/math/scribblings/math-number-theory.scrbl +++ b/collects/math/scribblings/math-number-theory.scrbl @@ -20,7 +20,7 @@ (parameterize ([sandbox-output 'string] [sandbox-error-output 'string]) (make-evaluator 'racket))) -@;(interaction-eval #:eval math-eval (require math)) +;(interaction-eval #:eval math-eval (require racket math)) @title[#:tag "number-theory" #:style '(toc)]{Number Theory} @@ -446,7 +446,6 @@ Note: The function @racket[divisor-sum] is multiplicative. (eulerian-number 5 2)] } - @defproc[(fibonacci [n Natural]) natural?]{ Returns the @racket[n]th Fibonacci number. Definition: @@ -507,4 +506,49 @@ Note: The function @racket[divisor-sum] is multiplicative. (multinomial 5 3 2)] } + + +@defproc[(partition-count [n Natural]) natural?]{ + Returns the number of partitions of @racket[n]. + A partition of a positive integer @racket[n] is a way + of writing @racket[n] as a sum of positive integers. + The number 3 has the partitions @math-style{1+1+1, 1+2, 3}. + See @url{http://en.wikipedia.org/wiki/Partition_(number_theory)}. + @interaction[(require math racket) + (partition-count 3) + (partition-count 4)] +} + + +@; ---------------------------------------- +@section[#:tag "special_numbers"]{Special Numbers} + +@subsection{Polygonal Numbers} + +@defproc[(triangle? [n Natural]) boolean?]{} +@defproc[(square? [n Natural]) boolean?]{} +@defproc[(pentagonal? [n Natural]) boolean?]{} +@defproc[(hexagonal? [n Natural]) boolean?]{} +@defproc[(heptagonal? [n Natural]) boolean?]{} +@defproc[(octagonal? [n Natural]) boolean?]{ +The functions +@racket[triangle?], @racket[square?], @racket[pentagonal?], +@racket[hexagonal?],@racket[heptagonal?] and @racket[octagonal?] +checks whether the input is a polygonal number of the types +triangle, square, pentagonal, hexagonal, heptagonal and octogonal +respectively. +} + +@defproc[(triangle [n Natural]) natural?]{} +@defproc[(sqr [n Natural]) natural?]{} +@defproc[(pentagonal [n Natural]) natural?]{} +@defproc[(hexagonal [n Natural]) natural?]{} +@defproc[(heptagonal [n Natural]) natural?]{} +@defproc[(octagonal [n Natural]) natural?]{ +The functions @racket[triangle], @racket[sqr], @racket[pentagonal], +@racket[hexagonal],@racket[heptagonal] and @racket[octagonal] +return the @racket[n]th polygonal number of the corresponding +type of polygonal number. +} + @(close-eval untyped-eval) \ No newline at end of file