程大位与剩余定理

  • 时间:2020-04-07 13:55:18
  • 分类:数学世界
  • 阅读:147 次

无论是《韩信点兵》的数学问题,还是《孙子算经》中“今有物不知其数,三三数之余二,五五数之余三,七七数之余二,问物几何?”都用到了被称为“中国剩余定埋”的解题方法,人们又叫它孙子问题。

到了明代,数学家程大位把《孙子算经》中的这个问题的算法编成了四句歌诀:

三人同行七十稀,

五树梅花廿一枝,

七子团圆正半月,

除百零五便得知。

用现在的话来说就是:一个数用3去除,除得的余数乘70;用5去除,除得的余数乘21;用7去除,除得的余数乘15,最后把这些乘积加起来再减去105的倍数,就知道这个数是多少。算式是:

70×2+21×3+15×2=233

233-105-105=23

所以,这些物品最少有23个。根据上面的算法,我们可以知道,韩信点兵时,必须知道部队的大概人数,否则也是无法算出准确人数的。

推荐阅读:
The Maximum Average Subtree of a Binary Tree  How to Design a Snake Game?  How to Design a Two-Sum Data Structure?  The MySQL If and Case Statement Exercise: How to Swap Elements i  Compute the Number of Ways to Paint the House via Dynamic Progra  How to Paint The Houses using Minimal Costs via Dynamic Programm  Relative Sort Array Algorithm: Sort Array Based on Predefined Se  Classic Unlimited Knapsack Problem Variant: Coin Change via Dyna  How to Remove Vowels from a String in C++?  The Beginners’ Guide to Trie: How to Use the Trie in C++? 
评论列表
添加评论