Starting from an initial number X, we can generate a series of numbers by applying these rules.

1. X must be prime, odd or divisible by 7

2. Take the last digit of X call it LX. Generate a ADDER (see rules fro generating ADDER belo. Add ADDER to LX to get a number FRON. Append FRONT at the beginning of X to get a new Value of X

3. Take X generated in 2 above and pick the middle number. Call it MX. If number of digits in X is even, then MX is the smaller of the two middle digits. Generate ADDER. Add ADDER to MX to get a number BACK. Append BACK at end of X to get a new value of X

4. Take X generated in 3 above and pick the first digit called FX. Generate ADDER. Add ADDER to FX to get a number, call it MID. Now ADD FRONT, BACK, MID to MX call it NM. Replace MX with NM and save this X.

5. Repeat the process to get other values of X

**Rules For Generating ADDER**

Lets say ADDER is Y then the

first Y is 1 if The initial number (X) is odd

first Y is 2 if The initial number (X) is divisible by 7

first Y is 3 if The initial number(X) is prime

Subsequents Y’s are generated by adding to previous Y’s. Let’s say Previous Y is PY and New Y id NY then

NY = PY + 1 if PY = 3

NY = PY + 3 if PY = 2

NY = PY + 5 if PY = 1

Subsequently, you add 1,3 or 5 to PY to get NY based on either you added 1, 3 or 5 to get PY.

If NY > 9 by adding 1 to PY, then NY = PY – 5, and subsequent Y’s are calculated thus NY = PY – 5

If NY 9 by adding 3 to PY, then NY = PY – 1, and subsequent Y’s are calculated thus NY = PY – 1

If NY 9 by adding 5, then NY = PY – 3, and subsequent Y’s are calculated thus NY = PY – 3

if NY < 1 by subtracting 3 from NY, then NY = PY + 1, and subsequent Y's are calculated thus NY = PY + 1

1. Write a program to generate these numbers.

2. Write a program to determine if a given number Q is a member of this series.

Where are the programmers in the house??

### Like this:

Like Loading...

*Related*

## Adedayo Ominiyi said

Interesting,

It doesn’t say anything about the size of d sequence although for your adder it seems you are trying to keep NY above zero and below 10 (0 < NY < 10). What kind of sequence are u trying to generate. P.S Just saw your email address will send you an email soonest

## Akintayo Olusegun said

Well the sequence can grow as large as possible. For what kind of number I am tryn to generate? I’ll say numbers that should be hard to guess