Staaarter

Generate Negafibonacci Numbers

Generates the first N negafibonacci numbers, the Fibonacci sequence extended to negative indices using the identity F(-n) = (-1)^(n+1) * F(n), with exact BigInt arithmetic. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-08-05
By Staaarter Team
fibonaccisequence

Overview

Introduction

The Fibonacci recurrence works just as well running backward as forward, which is how negafibonacci numbers, the Fibonacci sequence at negative indices, are defined.

This tool generates the first N negafibonacci terms, F(-1) through F(-N), with exact BigInt arithmetic so the alternating-sign values stay precise at any size.

What Is Generate Negafibonacci Numbers?

A generator for the sequence F(-1), F(-2), F(-3), and so on, where F(-n) = (-1)^(n+1) * F(n), the ordinary Fibonacci number at index n with an alternating sign applied.

The first several terms are 1, -1, 2, -3, 5, -8, 13, -21, mirroring the magnitudes of the standard Fibonacci sequence with signs flipping every other term.

How Generate Negafibonacci Numbers Works

The tool tracks the standard Fibonacci sequence internally, starting from F(0) = 0 and F(1) = 1, advancing one step per term.

At each step n, the current Fibonacci value F(n) is emitted with a positive sign if n is odd and a negative sign if n is even, matching the identity F(-n) = (-1)^(n+1) * F(n), using BigInt throughout so precision never degrades.

When To Use Generate Negafibonacci Numbers

Use it when you need the Fibonacci sequence's negative-index extension, for coursework on generalized Fibonacci numbers, Zeckendorf-style negafibonacci representations, or curiosity about the pattern.

For the ordinary forward sequence instead, use Fibonacci Number Generator.

Features

Advantages

  • Exact for any term within the 1000-term cap, computed with BigInt rather than floating-point arithmetic.
  • Correctly alternates sign automatically, no need to compute F(n) yourself and apply the sign rule by hand.
  • Fast, each term is a single BigInt addition plus a sign check.

Limitations

  • Capped at 1000 terms, matching the same practical limit as the forward Fibonacci sequence since the underlying magnitudes grow just as quickly.
  • Only outputs the negative-index sequence starting at n = -1, it does not also show the corresponding positive-index values alongside it.

Examples

First 6 negafibonacci numbers

Input

6

Output

1, -1, 2, -3, 5, -8

F(-1) through F(-6), matching the magnitudes of F(1) through F(6) with alternating sign.

First 3 negafibonacci numbers

Input

3

Output

1, -1, 2

Best Practices & Notes

Best Practices

  • Remember the indexing starts at n = -1, not n = 0, since F(-0) would just equal F(0) = 0 and isn't part of this alternating pattern.
  • If you need to compare against the standard sequence, generate matching counts from both this tool and Fibonacci Number Generator side by side.

Developer Notes

The implementation walks the standard Fibonacci recurrence forward with a BigInt pair, applying a sign based on the parity of the current step index rather than computing F(n) and F(-n) as two separate passes, which keeps the whole generator a single O(N) loop.

Generate Negafibonacci Numbers Use Cases

  • Studying generalized Fibonacci numbers and their negative-index extension
  • Generating reference values for negafibonacci (Zeckendorf-style) representation exercises
  • Verifying an implementation of the F(-n) = (-1)^(n+1) * F(n) identity

Common Mistakes

  • Expecting F(-1) to be negative, it's actually positive 1; the sign pattern starts positive and alternates from there.
  • Confusing this sequence's magnitudes with a different sequence entirely, they're identical to the ordinary Fibonacci numbers, only the sign changes.

Tips

  • Pair this with Negalucas Number Generator to compare how the two classic sequences behave at negative indices.
  • If you only need the magnitudes without the alternating sign, Fibonacci Number Generator already provides those directly.

References

Frequently Asked Questions