初学编程的必做数学题目
初学编程时,这些一定是必做的数学题目!
(1) 数字
奇数(Odd)偶数(Even) 奇数就是不能被2整除的整数。偶数就是能被2整除的整数。
闰年(Leap year) 能被4整除但不能被100整除,或能被400整除的年份即为闰年。
质数(Prime Number) 也叫素数,除了1和本身以外不再有其他因数的整数。如:2、3、5、7、11、13、17、19 https://en.wikipedia.org/wiki/Prime_number http://mathworld.wolfram.com/PrimeNumber.html
合数(Composite number) 与质数相反,除了能被1和本身整除外,还能被其他数整除的数。如:4、6、8、9、10 https://en.wikipedia.org/wiki/Composite_number http://mathworld.wolfram.com/CompositeNumber.html
完美数(Perfect number) 一个数恰好等于它的因子之和。如:6=1+2+3 https://en.wikipedia.org/wiki/Perfect_number http://mathworld.wolfram.com/PerfectNumber.html
亲和数(Amicable number) 如果两个数,你的所有真因数之和等于我,我的所有真因数之和等于你,则我们是一对亲和数。如:(220, 284), (1184, 1210) https://en.wikipedia.org/wiki/Amicable_numbers http://mathworld.wolfram.com/AmicablePair.html
回文数(Palindrome number) 一个数正读和反读是相同的整数。如:16461 https://en.wikipedia.org/wiki/Palindromic_number http://mathworld.wolfram.com/PalindromicNumber.html
水仙花数(Narcissistic number) 一个三位数等于每个数字的n次幂之和。如:153=1^3+5^3+3^3。水仙花数共有4个,分别为:153、370、371、407。 阿姆斯特朗数(Armstrong number) 比水仙花数范围大,不局限于三位数。 https://en.wikipedia.org/wiki/Narcissistic_number http://mathworld.wolfram.com/NarcissisticNumber.html
斐波那契数列(Fibonacci number) 每一个数都是它前面两个数的和。 F(n)=F(n-1)+F(n-2) 具体数列为:1,1,2,3,5,8,13,21,34,55,89,144,... 泰波那契数列(Tribonacci number) 把斐波那契数列的概念推广至三个数。 T(n)=T(n-1)+T(n-2)+T(n-3) https://en.wikipedia.org/wiki/Fibonacci_number http://mathworld.wolfram.com/FibonacciNumber.html
勾股数(Pythagorean Triple) a^2+b^2=c^2 https://en.wikipedia.org/wiki/Pythagorean_triple http://mathworld.wolfram.com/PythagoreanTriple.html
π PI=4*(1-1/3+1/5-1/7+1/9-1/11+1/13-1/15+...) https://en.wikipedia.org/wiki/Pi http://mathworld.wolfram.com/Pi.html
调和级数(Harmonic series) H(n)=1+1/2+1/3+1/4+...+1/n https://en.wikipedia.org/wiki/Harmonic_series_(mathematics) http://mathworld.wolfram.com/HarmonicSeries.html
(2) 运算
求和(Sum) 1+2+3+...+n https://en.wikipedia.org/wiki/Summation http://mathworld.wolfram.com/Sum.html
阶乘(Factorial) n!=n*(n-1)...2*1 https://en.wikipedia.org/wiki/Factorial http://mathworld.wolfram.com/Factorial.html
约数(Factor/Divisor) https://en.wikipedia.org/wiki/Divisor http://mathworld.wolfram.com/Divisor.html
最大公约数(GCD:Greatest Common Divisor) https://en.wikipedia.org/wiki/Greatest_common_divisor http://mathworld.wolfram.com/GreatestCommonDivisor.html
最小公倍数(LCM:Lowest Common Multipl) https://en.wikipedia.org/wiki/Least_common_multiple http://mathworld.wolfram.com/LeastCommonMultiple.html
(3) 打印图形
金字塔Pyramid、菱形Diamond

箭头

其他形状

帕斯卡三角(Pascal Triangle) 也叫杨辉三角

九九乘法表(Multiplication Table)

(4) 汉诺塔(Hanoi Tower)
有A、B和C 3跟柱子,在A上从下往上按照从小到大的顺序放着64个圆盘,以B为中介,把盘子全部移动到C上。移动过程中,要求任意盘子的下面要么没有盘子,要么只能有比它大的盘子。
https://en.wikipedia.org/wiki/Tower_of_Hanoi