id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

jebbert@volusia.k12.fl.us > nov9_2015_HL_fibLikeSequence
prev  |  next  |  chance

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)

public boolean nov9_2015_HL_fibLikeSequence(int first, int second, int target) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 280

Copyright Nick Parlante 2017 - privacy