Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.
A:
#method1
a = 1
b = 1
c = a + b
result = 0
while (c < 4000000):
result += c
a = b + c
b = c + a
c = a + b
print "result=%d" %result
#method2
x = y = 1
sum = 0
while (sum < 4000000):
sum += (x + y)
x, y = x + 2 * y, 2 * x + 3 * y
print sum
分享到:
相关推荐
Topological Spaces: Including a Treatment of Multi-Valued Functions, Vector Spaces and Convexity Topological Spaces: Including a Treatment of Multi-Valued Functions, Vector Spaces and Convexity ...
这是计算机类相关专业关于机器学习、深度学习的数学工具书。可以在用到的时候查阅。专门关于复数域导数运算的工具书。
6.2 Derivatives of Mixture of Real- and Complex-Valued Matrix Variables 137 6.2.1 Chain Rule for Mixture of Real- and Complex-Valued Matrix Variables 139 6.2.2 Steepest Ascent and Descent Methods for ...
On the handling of Continuous-valued attributes in decisiontree generation
Chan_Active-Contours-without-Edges-for-Vector-Valued-Images_Journal-of-Visual-Communication-and-Image-Representation_2000.pdf
英文版-复数矩阵的求导公式的详细的推导过程及结论<Complex-valued_matrix_derivatives>
Vector-Valued Optimization Problems in Control Theory (M. E. Salukvadze) 控制论
Abstract This chapter contains sections titled: Introduction Derivatives in Wirtinger Calculus Complex Gradient Learning Algorithms for Feedforward CVNNs Learning Algorithms for Recurrent CVNNs ...
spective they are the key in the context of Gaussian processes, where the kernel function is known as the covariance function. Traditionally, kernel methods have been used in supervised learning ...
Fuzzy sets in the preprocessing and enhancements of training data 6.4.1. Nonlinear data normalization 6.4.2. Variable processing resolution - fuzzy receptive fields 6.5. Uncertainty ...
Statistical SIgnal processing of complex-valued data: the theory
2 Kronecker products, the vec operator and the Moore-Penrose inverse 31 1Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 2The Kronecker product . . . . . . . . . . . . . . . ...
abbreviated 3VL) is any of several many-valued logic systems in which there are three truth values indicating true, false and some indeterminate third value. This is contrasted with the more commonly ...
Routing TCP/IP, Volume II expands upon the central theme of Volume I: scalability and management of network growth. Volume II moves beyond the interior gateway protocols covered in Volume I to examine...
This paper describes a low power implementation of the Bluetooth Subband CODEC (SBC) for high-fidelity wireless audio. The design uses a configurable Weighted Overlap-Add (WOLA) filterbank ...
14 The equations X 1 A + X 2 B ′ = G 1 ,X 1 B = G 2 . . . . . . . . . . 68 Miscellaneous exercises . . . . . . . . . . . . . . . . . . . . . . . . . . 71 Bibliographical notes . . . . . . . . . . . ....
复值时滞神经网络的拉格朗日稳定性,涂正文,曹进德,本文研究了复值时滞神经网络的Lagrange稳定性,借助于矩阵测度和广义的Halanay 不等式获得了能保证复值时滞神经网络拉格朗日指数稳定的�
欧拉公式求长期率的matlab代码欧拉计划问题与解决方案 这是一个用于存储网站问题解决方案的存储库。 要讨论/查看针对特定问题的各种解决方案,请分叉此存储库,并发送提及该解决方案的请求...even-valued terms. '''
Using the method of maximizing deviations to multiple attribute decision making under interval-valued intuitionistic fuzzy environment,卫贵武,,With respect to multiple attribute decision making ...
- Introduce the rules for computing the derivative of complex-valued functions. -Provide applications in signal processing and communications. - A great handbook for both research and engineering.