← 返回
未分类 中文

Fibonacci Generator

Generate and work with Fibonacci sequences and related number sequences. Use when users need Fibonacci numbers, calculate Fibonacci sequences, find nth Fibon...
生成和处理斐波那契数列及相关数列。当用户需要斐波那契数、计算斐波那契数列或找出第 n 个斐波那契数时使用。
terrycarter1985 terrycarter1985 来源
未分类 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 290
下载
💾 0
安装
1
版本
#latest

概述

Fibonacci Sequence Generator

Generate Fibonacci sequences and work with Fibonacci numbers, golden ratios, and related mathematical concepts.

Quick Start

Basic Usage

The Fibonacci sequence starts with 0, 1, and each subsequent number is the sum of the two preceding ones.

First 10 Fibonacci numbers: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34

Generate First N Numbers

def fibonacci(n):
    """Generate first n Fibonacci numbers."""
    if n <= 0:
        return []
    elif n == 1:
        return [0]
    seq = [0, 1]
    for i in range(2, n):
        seq.append(seq[-1] + seq[-2])
    return seq

Common Operations

Nth Fibonacci Number (0-indexed)

def nth_fibonacci(n):
    """Get the nth Fibonacci number (0-indexed)."""
    a, b = 0, 1
    for _ in range(n):
        a, b = b, a + b
    return a

Check if Number is Fibonacci

import math

def is_fibonacci(x):
    """Check if x is a Fibonacci number."""
    def is_perfect_square(n):
        s = int(math.sqrt(n))
        return s * s == n
    return is_perfect_square(5 * x * x + 4) or is_perfect_square(5 * x * x - 4)

Golden Ratio Approximation

As n increases, the ratio F(n+1)/F(n) approaches the golden ratio φ ≈ 1.618033988749895

Related Sequences

Lucas Numbers

Similar to Fibonacci but starts with 2, 1

Tribonacci

Each number is sum of previous three

Fibonacci Sum

Sum of first n Fibonacci numbers = F(n+2) - 1

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-21 14:22 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

dev-programming

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 681 📥 329,281
dev-programming

Mcporter

steipete
使用 mcporter CLI 直接列出、配置、认证及调用 MCP 服务器/工具(支持 HTTP 或 stdio),涵盖临时服务器、配置编辑及 CLI/类型生成功能。
★ 196 📥 67,934
dev-programming

CodeConductor.ai

larsonreever
AI驱动平台,提供快速全栈开发、智能体、工作流自动化及低代码AI集成的可扩展产品创建。
★ 75 📥 182,401