Jobs
Interviews

Solve Find Next Number in Sequence using Lua Language

Solve Find Next Number in Sequence using Lua to enhance your skills with lua coding practice , master coding concepts, and prepare for interviews with practical exercises and detailed solutions.

Find Next Number in Sequence

Difficulty : Easy

Categories :

  • Mathematics

Given a sequence of three numbers forming an arithmetic or geometric sequence, find the next number in the sequence. A sequence is arithmetic if the difference between consecutive terms is constant, and geometric if the ratio between consecutive terms is constant.

Constraints:

  • -10⁴ ≤ numbers ≤ 10⁴
  • The sequence is guaranteed to be either arithmetic or geometric
  • For geometric sequences, all numbers will be non-zero
  • The answer will fit in a 32-bit integer

Examples:

Input: [2,4,6]
Output: 8
Explanation: Arithmetic sequence with difference of 2
Input: [2,4,8]
Output: 16
Explanation: Geometric sequence with ratio of 2

Problem Solving

Input

What You'll Find Here

Real-World Applications Solve problems inspired by Lua's common use cases, such as game development and embedded systems.

Step-by-Step Guidance Break down Lua's concepts into digestible lessons.

Practical Skills Build hands-on experience with Lua for real-world projects.

Choose from the following categories