← 返回 waymo 的题目列表Implement a Fibonacci Generator
类型:online_judge
Problem: Implement a Fibonacci Generator
Implement a Fibonacci sequence generator in Python that yields Fibonacci numbers in order.
Fibonacci definition:
F(0) = 0
F(1) = 1
F(n) = F(n-1) + F(n-2) for n >= 2
Requirements
Implement it as a generator (use yield) to produce values lazily.
The generator should start from F(0) and produce: 0, 1, 1, 2, 3, 5, ...
Given an input n, output the first n Fibonacci numbers (n >= 0).
Write a complete program: read n from stdin, print the first n numbers separated by spaces to stdout.
Constraints
0 <= n <= 1e5
Example
Input: 5
Output: 0 1 1 2 3
Example
Input
0
Output