---
title: "Problem15"
author: "mlkimg"
date: "2010-09-11T23:49:43Z"
tags: []
categories: ["编程语言"]
slug: "problem15"
draft: false
lastmod: "2010-09-11T23:59:49Z"
id: 761156
url: "https://mlkimg.iteye.com/blog/761156"
---

题目：Starting in the top left corner of a 2![×](http://projecteuler.net/images/symbol_times.gif)2 grid, there are 6 routes (without backtracking) to the bottom right corner.

![](http://projecteuler.net/project/images/p_015.gif)

How many routes are there through a 20![×](http://projecteuler.net/images/symbol_times.gif)20 grid?

 

```
a=Array.new(21){Array.new(21)}

  for i in 1..20
    a[0][i]=1
    a[i][0]=1
  end

1.upto(20) do |i|
  1.upto(20) do |j|
    a[i][j]=a[i-1][j]+a[i][j-1]
  end
end

p a
```

 

看看下面的表格：

![](http://mathschallenge.net/problems/images/2004_05_3_2.gif)

其实就是杨辉三角嘛