📄 fibonacciprogression-fib.html
字号:
<html><head><title>Code Fragment</title></head><body text=#000000><center></center><br><br><dl><dd><pre><font color=#ff0080>/** * Fibonacci progression. */</font><font color=#ff8000>class</font> <font color=#8000a0>FibonacciProgression </font><font color=#ff8000>extends</font> Progression { <font color = #ff0080>/** Previous value. */</font> <font color=#8000a0>long </font>prev; <font color=#ff0080>// Inherits variables first and cur.</font> <font color = #ff0080>/** Default constructor setting 0 and 1 as the first two values. */</font> <font color=#0000ff>FibonacciProgression</font>() { <font color=#ff8000>this</font><font color=#0000ff></font>(0, 1); } <font color=#ff0080>/** Parametric constructor providing the first and second values. * * @param value1 first value. * @param value2 second value. */</font> <font color=#0000ff>FibonacciProgression</font>(long value1, <font color=#8000a0>long </font>value2) { first = value1; prev = value2 - value1; <font color=#ff0080>// fictitious value preceding the first</font> } <font color=#ff0080>/** Advances the progression by adding the previous value to the current value. * * @return next value of the progression */</font> <font color=#8000a0><font color=#8000a0>protected</font> </font>long <font color=#0000ff>nextValue</font>() { <font color=#8000a0>long </font>temp = prev; prev = cur; cur += temp; <font color=#8000a0><font color=#ff8000>return</font> </font>cur; } <font color=#ff0080>// Inherits methods firstValue() and printProgression(int).</font>}</dl></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -