×

# fibonacci modified

 0 https://www.hackerrank.com/challenges/fibonacci-modified/problem i found this question on hackerrank. can anyone explain how this can be solved using c++ . asked 26 Oct '18, 05:44 0 accept rate: 0%

 0 @sumesh -- The basics of the solution is a simple loop. This is pseudocode...  declare t_Nminus2 := t1 // function parameter declare t_Nminus1 := t2 // function parameter declare t_N for i := 3 to n inclusive // n is a function parameter t_N := t_Nminus2 + t_Nminus1 * t_Nminus1 t_Nminus2 := t_Nminus1 t_Nminus1 := t_N end for return t_N  The challenge isn't the base algorithm outlined above. The challenge is the datatype to use for t_N. Since n can be up to 20 and the next term includes the square of the prior term, the max possible value of t_N is much larger than ULLONG_MAX (largest possible unsigned long long int), as the HackerRank problem statement says. There is no native data type in C++ that can handle such large integers, so it's possible this problem wants you to create your own datatype. answered 27 Oct '18, 23:11 58●3 accept rate: 16%
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×2,559
×2,093
×3

question asked: 26 Oct '18, 05:44

question was seen: 108 times

last updated: 27 Oct '18, 23:12