我想检查我的数字是否是斐波那契?
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
<Context docBase="Booking" path="/Booking" reloadable="true" />
</Host>
答案 0 :(得分:-1)
<?php
function getFibonicciIndex($number)
{
$log_base = (1+sqrt(5))/2;
$index = log(($number*sqrt(5)-(1/2)), $log_base);
return floor($index)+1;
}
function getFibonicciNumber($term)
{
$a = (1+sqrt(5))/2;
$b = (1-sqrt(5))/2;
$fibonicci_number = (pow($a, $term)-pow($b, $term))/sqrt(5);
return $fibonicci_number;
}
$number = 14;
$index = getFibonicciIndex($number);
$index_value = getFibonicciNumber($index);
echo ($number == $index_value) ? "yes" : "no";
//此逻辑实现了查找斐波纳契数列及其索引的最佳规则。首先,我们假设给定的没有。是Fibonacci系列的一部分,并尝试获得索引..然后对于给定的索引,我们计算斐波那契数并将其等于验证