We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. Prepare
  2. Mathematics
  3. Fundamentals
  4. Is Fibo
  5. Discussions

Is Fibo

Problem
Submissions
Leaderboard
Discussions
Editorial
Topics

Sort 369 Discussions, By:

recency

Please Login in order to post a comment

  • johnny_molyneux
    5 days ago+ 0 comments
        public static string isFibo(long n)
        {
            double squareTest = (5 * Math.Pow((double)n, 2)) + 4;
            double sqrt = Math.Sqrt(squareTest);
            
            if(sqrt % 1 == 0)
                return "IsFibo";
            
            squareTest = (5 * Math.Pow((double)n, 2)) - 4;
            sqrt = Math.Sqrt(squareTest);
            
            if(sqrt % 1 == 0)
                return "IsFibo";
            
            return "IsNotFibo";
        }
    
    0|
    Permalink
  • whunterknight
    2 weeks ago+ 0 comments

    return "IsNotFibo" if (5*n**2+4)**0.5 % 1 and (5*n**2-4)**0.5 % 1 else "IsFibo"

    0|
    Permalink
  • georgetmeier1
    2 months ago+ 0 comments

    python3 using a generator

    def fib(): a, b = 0, 1 while True: yield a a, b = b, a+b

    def isFibo(n): # Write your code here f = fib() a = next(f) while a < n: a = next(f) if a == n: return 'IsFibo' else: return 'IsNotFibo'

    0|
    Permalink
  • chisom213
    3 months ago+ 0 comments
    def isFibo(n):
        a, b = 0, 1
        lst = [a, b]
        while b < n:
          a, b = b, a+b
          lst.append(b)
        return 'IsFibo' if n in lst else 'IsNotFibo'
    
    0|
    Permalink
  • muhsen_kaamil
    5 months ago+ 0 comments

    Python 3 Binet's formula

    def IsFibo(n):
        return ('IsNotFibo', 'IsFibo')[any(filter(lambda x: x%1==0, (sqrt(5*n**2+4), sqrt(5*n**2-4))))]
    
    0|
    Permalink
Load more conversations

Need Help?


View editorial
View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy