about | help | code help+videos | done | prefs |
Write a method that determines if a given 'target' number occurs in a "Fibonacci-like" sequence. The Fibonacci Sequence is 1, 1, 2, 3, 5, 8, 13, 21, 34, etc. where the first two numbers are 1's and each consecutive number is found by adding the two previous numbers. So the next number in the sequence is 21+34=55. A "Fibonacci-like" sequence follows the same rules, except that the first two numbers can be any numbers. Consecutive numbers after the first two are still found by adding the two previous numbers. Return 'true' if 'target' occurs in the given "Fibonacci-like" sequence, return 'false' otherwise. You are NOT allowed to use any arrays or any string operations. Please note that 'first' and 'second' will be positive integers. nov9_2015_HL_fibLikeSequence(5, 1, 7) → true nov9_2015_HL_fibLikeSequence(5, 1, 14) → false nov9_2015_HL_fibLikeSequence(10, 20, 55) → false ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 280
Copyright Nick Parlante 2017 - privacy