• Post Reply Bookmark Topic Watch Topic
  • New Topic

Predict Sequence of Numbers?!  RSS feed

 
Shafian Kisna
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following qn and I am in doubt how to get started. I have a few formulas but the problem is I am uncertain how to equate in Java.

From the start program, I would provide a series of numbers and based on the numbers, I have to equate to see which best fits into the formula. It has to determine which type(s) of sequence these numbers could belong to, and in each case predict the next five numbers in the sequence.


Formulas are
Constant uk = a
Arithmetic uk = uk-1+b
Geometric uk = ruk-1
Recurrent uk = auk-1 + buk-2 + c


Appreciate your help!!!
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like a homework question and certainly not advanced Java - more like beginner. But it's Friday and I'm feeling generous, so some clues anyway...

Look at the given numbers. If they're all the same, it's constant series.

Look at the differences between the given numbers. If all the differences are the same, it's arithmetic.

Look at the ratios of adjacent given numbers. If the ratios are all the same, it's geometric. Take care: if you use integer arithmetic, you could get false positives here. But if you use floating-point, you could get false negatives, unless you round appropriately.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!