- (*边长均小于100的整边非本原海伦三角形一共有多少个呢?*)
- Clear["Global`*"];(*清除所有变量*)
- (*子函数,海伦公式,利用海伦公式计算三角形的面积*)
- heron[a_,b_,c_]:=Module[{p=(a+b+c)/2},Sqrt[p*(p-a)*(p-b)*(p-c)]]
- aaa=Table[k,{k,1,99}];(*产生前99个数*)
- bbb2=Tuples[aaa,3];(*得到三元数组*)
- bbb=Select[bbb2,And[#[[1]]<=#[[2]],#[[2]]<=#[[3]]]&];(*选择递增的*)
- ccc=Select[bbb,And[(heron@@#)^2>0]&];(*选择面积平方大于零的*)
- ddd=Select[ccc,IntegerQ[heron@@#]&];(*选择面积为整数的*)
- eee=Append[#,heron@@#]&/@ddd (*增加面积*)
- Dimensions[eee](*计算维度*)
复制代码
输出结果:
- {{3,4,5,6},{3,25,26,36},{4,13,15,24},{4,51,53,90},{5,5,6,12},{5,5,8,12},{5,12,13,30},{5,29,30,72},{5,51,52,126},{6,8,10,24},{6,25,29,60},{6,50,52,144},{7,15,20,42},{7,24,25,84},{7,65,68,210},{8,15,17,60},{8,26,30,96},{8,29,35,84},{9,10,17,36},{9,12,15,54},{9,40,41,180},{9,65,70,252},{9,73,80,216},{9,75,78,324},{10,10,12,48},{10,10,16,48},{10,13,13,60},{10,17,21,84},{10,24,26,120},{10,35,39,168},{10,58,60,288},{11,13,20,66},{11,25,30,132},{11,60,61,330},{11,90,97,396},{12,16,20,96},{12,17,25,90},{12,35,37,210},{12,39,45,216},{12,50,58,240},{12,55,65,198},{13,13,24,60},{13,14,15,84},{13,20,21,126},{13,30,37,180},{13,37,40,240},{13,40,45,252},{13,40,51,156},{13,68,75,390},{13,84,85,546},{14,25,25,168},{14,30,40,168},{14,48,50,336},{14,61,65,420},{15,15,18,108},{15,15,24,108},{15,20,25,150},{15,26,37,156},{15,28,41,126},{15,34,35,252},{15,36,39,270},{15,37,44,264},{15,41,52,234},{15,52,61,336},{15,87,90,648},{16,17,17,120},{16,25,39,120},{16,30,34,240},{16,52,60,384},{16,58,70,336},{16,63,65,504},{17,17,30,120},{17,25,26,204},{17,25,28,210},{17,28,39,210},{17,39,44,330},{17,40,41,336},{17,55,60,462},{17,65,80,288},{17,89,90,756},{18,20,34,144},{18,24,30,216},{18,41,41,360},{18,75,87,540},{18,80,82,720},{19,20,37,114},{19,60,73,456},{20,20,24,192},{20,20,32,192},{20,21,29,210},{20,26,26,240},{20,34,42,336},{20,37,51,306},{20,48,52,480},{20,51,65,408},{20,53,55,528},{20,65,75,600},{20,70,78,672},{21,28,35,294},{21,41,50,420},{21,45,60,378},{21,61,68,630},{21,72,75,756},{21,82,89,840},{22,26,40,264},{22,50,60,528},{22,61,61,660},{22,85,91,924},{24,32,40,384},{24,34,50,360},{24,35,53,336},{24,37,37,420},{24,45,51,540},{24,70,74,840},{24,78,90,864},{25,25,30,300},{25,25,40,300},{25,25,48,168},{25,29,36,360},{25,33,52,330},{25,34,39,420},{25,38,51,456},{25,39,40,468},{25,39,56,420},{25,51,52,624},{25,51,74,300},{25,52,63,630},{25,60,65,750},{25,63,74,756},{25,74,77,924},{26,26,48,240},{26,28,30,336},{26,35,51,420},{26,40,42,504},{26,51,55,660},{26,51,73,420},{26,60,74,720},{26,73,97,420},{26,74,80,960},{26,75,91,840},{26,80,90,1008},{26,85,85,1092},{27,29,52,270},{27,30,51,324},{27,36,45,486},{28,45,53,630},{28,50,50,672},{28,60,80,672},{28,65,89,546},{29,29,40,420},{29,29,42,420},{29,35,48,504},{29,52,69,690},{29,52,75,546},{29,60,85,522},{29,65,68,936},{29,75,92,966},{30,30,36,432},{30,30,48,432},{30,39,39,540},{30,40,50,600},{30,51,63,756},{30,52,74,624},{30,56,82,504},{30,68,70,1008},{30,72,78,1080},{30,74,88,1056},{31,68,87,930},{32,34,34,480},{32,50,78,480},{32,53,75,720},{32,60,68,960},{32,65,65,1008},{33,34,65,264},{33,39,60,594},{33,41,58,660},{33,44,55,726},{33,56,65,924},{33,58,85,660},{33,75,90,1188},{34,34,60,480},{34,50,52,816},{34,50,56,840},{34,55,87,396},{34,56,78,840},{34,61,75,1020},{34,65,93,744},{34,78,88,1320},{34,80,82,1344},{35,35,42,588},{35,35,56,588},{35,44,75,462},{35,52,73,840},{35,53,66,924},{35,65,82,1092},{35,78,97,1260},{35,84,91,1470},{36,40,68,576},{36,48,60,864},{36,51,75,810},{36,61,65,1080},{36,77,85,1386},{36,82,82,1440},{37,37,70,420},{37,39,52,720},{37,72,91,1260},{37,91,96,1680},{38,40,74,456},{38,65,87,1140},{39,39,72,540},{39,41,50,780},{39,42,45,756},{39,52,65,1014},{39,55,82,924},{39,58,95,456},{39,60,63,1134},{39,62,85,1116},{39,80,89,1560},{39,85,92,1656},{40,40,48,768},{40,40,64,768},{40,42,58,840},{40,51,77,924},{40,52,52,960},{40,68,84,1344},{40,75,85,1500},{41,41,80,360},{41,50,73,984},{41,50,89,420},{41,51,58,1020},{41,60,95,798},{41,66,85,1320},{41,84,85,1680},{42,56,70,1176},{42,75,75,1512},{43,61,68,1290},{44,52,80,1056},{44,65,87,1386},{44,75,97,1584},{45,45,54,972},{45,45,72,972},{45,50,85,900},{45,60,75,1350},{48,51,51,1080},{48,55,73,1320},{48,64,80,1536},{48,74,74,1680},{48,85,91,2016},{50,50,60,1200},{50,50,80,1200},{50,50,96,672},{50,58,72,1440},{50,65,65,1500},{50,68,78,1680},{50,69,73,1656},{50,78,80,1872},{51,51,90,1080},{51,52,53,1170},{51,52,97,840},{51,68,85,1734},{51,75,78,1836},{51,75,84,1890},{52,52,96,960},{52,56,60,1344},{52,61,87,1560},{52,73,75,1800},{52,80,84,2016},{53,53,56,1260},{53,53,90,1260},{53,75,88,1980},{54,72,90,1944},{55,55,66,1452},{55,55,88,1452},{56,61,75,1680},{57,65,68,1710},{57,76,95,2166},{57,82,89,2280},{58,58,80,1680},{58,58,84,1680},{58,70,96,2016},{60,60,72,1728},{60,60,96,1728},{60,63,87,1890},{60,73,91,2184},{60,78,78,2160},{61,74,87,2220},{64,68,68,1920},{65,65,66,1848},{65,65,78,2028},{65,70,75,2100},{65,72,97,2340},{65,76,87,2394},{65,87,88,2640},{68,75,77,2310},{68,87,95,2850},{70,70,84,2352},{70,91,91,2940},{72,85,85,2772},{73,73,96,2640},{75,75,90,2700},{75,86,97,3096},{78,84,90,3024},{78,89,89,3120},{78,95,97,3420},{80,80,96,3072},{80,85,85,3000}}
复制代码 |