XCODE01 - Editorial

Problem Link

[Contest][1]

Practice

Author: Sahil Rajput

Tester: Sahil Rajput

Editorialist: Sahil Rajput

Difficulty

EASY

Prerequisites

Maths

Problem

Given a number N, task is to check whether that number exist in fibonacci series or not.

Explanation

A simple way is to generate fibonacci number until the generated number is greater than or equal to ’n’ but this approach will give you 70 points. For 100 points, you have to use the [property of fibonacci number][6] that can also be used to check if a given number is Fibonacci or not.

A number is Fibonacci if and only if one or both of (5n^2 + 4) or (5n^2 – 4) is a perfect square.

Solution Link

[Setter's solution][7]