########################################################################## # Copyright (C) 2006 Jaap Spies, jaapspies@gmail.com # Copyright (C) 2006 William Stein, wstein@gmail.com # # Distributed under the terms of the GNU General Public License (GPL): # # http://www.gnu.org/licenses/ ########################################################################## def A079912(n): r""" function returns solutions to the Dancing School problem with 7 girls The value is $per(B)$, the permanent of the (0,1)-matrix $B$ of size $7 \times 7+n$ with $b(i,j)=1$ if and only if $i \le j \le i+n$. We use precalculated values for $n = 0, ..., 4$ For $n > 4$ we use the polynomial $n^7-14*n^6+126*n^5-700*n^4+2625*n^3-6342*n^2+9072*n-5840$ calculated with the function dance. See http://www.jaapspies.nl/mathfiles/dancing.sage See Nieuw Archief voor Wiskunde 5/7 nr. 4 December 2006 p. 285 INPUT: n -- non negative number OUTPUT integer EXAMPLES: sage: A079912(4) 5794 sage: A079912(10) 3675680 sage: A079912(20) 693838800 sage: A079912(1000) 986125302618667066160 AUTHOR: - Jaap Spies (2006-12-10) """ b = [1, 8, 133, 1044, 5794 ] if n >= 0 and n <= 4: return b[n] else: return n^7-14*n^6+126*n^5-700*n^4+2625*n^3-6342*n^2+9072*n-5840 def A079912_list(n): r""" function returns list of solutions to the Dancing School problem with 7 girls We use precalculated values for $n = 0, 1, 2, 3, 4$. For $n > 4$ we use the polynomial $h^7-14*h^6+126*h^5-700*h^4+2625*h^3-6342*h^2+9072*h-5840$ calculated with the function dance. See http://www.jaapspies.nl/mathfiles/dancing.sage INPUT: n -- non negative number OUTPUT list of integers EXAMPLES: sage: print A079912_list(10) [1, 8, 133, 1044, 5794, 24720, 86608, 260720, 693552, 1666000, 3675680] sage: print A079912_list(1) [1, 8] sage: print A079912_list(0) [1] sage: A079912_list(3) [1, 8, 133, 1044] AUTHOR: - Jaap Spies (2006-12-10) """ h = QQ['h'].gen() b = [1, 8, 133, 1044, 5794 ] if n >= 0 and n <= 4: return b[:n+1] else: pol = h^7-14*h^6+126*h^5-700*h^4+2625*h^3-6342*h^2+9072*h-5840 a = [pol(i) for i in range(5, n+1)] for i in range(5): a.insert(i,b[i]) return a