Pythagorean theorem

 

Pythagorean theorem: 勾股定理; 毕达哥拉斯定理; 毕氏定理

 

一直不知道初中数学学得勾股定理的英文翻译竟然是Pythagorean theorem,勾股定理应该是每个编程人员都必须知道的数学基本知识,尤其编写图形库类似程序,3D/2D等。

 

很多人都知道这个定理,却忘了怎么证明这个定理,看下图

 

 

 

 

 

用haskell简单写个1000以内的所有Pythagorean组合:

 

Prelude> [[x,y,z] | x<-[1..1000], y<-[1..1000], z<-[1..1000], x<=y, x^2+y^2==z^2]
[[3,4,5],[5,12,13],[6,8,10],[7,24,25],[8,15,17],[9,12,15],[9,40,41],[10,24,26],[11,60,61],[12,16,20],[12,35,37],[13,84,85],[14,48,50],[15,20,25],[15,36,39],[15,112,113],[16,30,34],[16,63,65],[17,144,145],[18,24,30],[18,80,82],[19,180,181],[20,21,29],[20,48,52],[20,99,101],[21,28,35],[21,72,75],[21,220,221],[22,120,122],[23,264,265],[24,32,40],[24,45,51],[24,70,74],[24,143,145],[25,60,65],[25,312,313],[26,168,170],[27,36,45],[27,120,123],[27,364,365],[28,45,53],[28,96,100],[28,195,197],[29,420,421],[30,40,50],[30,72,78],[30,224,226],[31,480,481],[32,60,68],[32,126,130],[32,255,257],[33,44,55],[33,56,65],[33,180,183],[33,544,545],[34,288,290],[35,84,91],[35,120,125],[35,612,613],[36,48,60],[36,77,85],[36,105,111],[36,160,164],[36,323,325],[37,684,685],[38,360,362],[39,52,65],[39,80,89],[39,252,255],[39,760,761],[40,42,58],[40,75,85],[40,96,104],[40,198,202],[40,399,401],[41,840,841],[42,56,70],[42,144,150],[42,440,442],[43,924,925],[44,117,125],[44,240,244],[44,483,485],[45,60,75],[45,108,117],[45,200,205],[45,336,339],[46,528,530],[48,55,73],[48,64,80],[48,90,102],[48,140,148],[48,189,195],[48,286,290],[48,575,577],[49,168,175],[50,120,130],[50,624,626],[51,68,85],[51,140,149],[51,432,435],[52,165,173],[52,336,340],[52,675,677],[54,72,90],[54,240,246],[54,728,730],[55,132,143],[55,300,305],[56,90,106
 

 

 

你可能感兴趣的:(haskell)