Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem: Given five integers that make a series determine the next five numbers

ID: 3538220 • Letter: P

Question

Problem: Given five integers that make a series determine the next five numbers in the series. There are only two possible series and they are defined as follows:

1. Addition %u2013 Each number in the series is separated by the same amount.
2. Multiplication %u2013 Each number in the series is a product of the previous number in the series and a constant integer
value.

Example Execution #1:

Example Execution #2:

Example Execution #3:

Example Execution #4:

Example Execution #5:

Enter the first five number of the series: 1 2 3 4 5
The next number five numbers in the series are: 6 7 8 9 10

The use of any selection constructs (if/else, switch, conditional expressions), logical and relational operators (&&, ||, !, <, <=, ==, >=, >), and Boolean variables are prohibited on this assignment. Only user defined functions can be can be used.

I need the code and the logic. Will Award full points who gives the correct code.

Explanation / Answer

#include <stdio.h>



void nextFiveNumber(){

long long int prev;


long long int next;


long long int first;



printf("Enter the first five number of the series: ");



scanf("%lld",&prev);


first = prev;


scanf("%lld",&next);


long long int diff = next - prev;


long long int temp = diff;


long long int factor = next/prev;


prev = next;


scanf("%lld",&next);


temp -= next-prev;


prev = next;


scanf("%lld",&next);


prev = next;


scanf("%lld",&next);


prev = next;



int c = -temp/(first*(factor-1)*(factor-1));



printf("The next number five numbers in the series are: ");


prev = ((c+1)%2)*(prev + diff) + c*(prev*factor);


printf("%lld ",prev);


prev = ((c+1)%2)*(prev + diff) + c*(prev*factor);


printf("%lld ",prev);


prev = ((c+1)%2)*(prev + diff) + c*(prev*factor);


printf("%lld ",prev);


prev = ((c+1)%2)*(prev + diff) + c*(prev*factor);


printf("%lld ",prev);


prev = ((c+1)%2)*(prev + diff) + c*(prev*factor);


printf("%lld ",prev);


}


int main(){

nextFiveNumber();

}



Logic is simple, first take input of 2 numbers and calculate factor and diff

lets say series is a b c d e

in case of sum

c-b - b-a = 0, but in case of multiply c-b - b-a = a(factor-1)^2


then calculate the value bases on the c value which will be 0 and 1 based series is sum or multiply

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote