-3
WITH NumberSequence AS
(
SELECT
1 AS Number1
, 2 AS Number2
UNION ALL
SELECT
Number2 * 2 + 1
, Number1 * 5
FROM NumberSequence
WHERE Number1 < 200
)
SELECT
*
FROM NumberSequence

Number1 Number2
   1       2
   5       5
   11      25
   51      55
   111     255
   511     555

I don't understand why its giving this output. Why we just don't multiply Number1 with 5. Why we swap the process between numbers. Can somebody explain to me please.

I found this question in the final exam of the past years. But I don't understand how the result turned out like this. Shouldn't the result of column Number1 continue like 1-5-25-125? and the result of the number2 column should be in the form of 2-5-11-23, right? step by step, I want to know where what process is taking place

0

1 Answer 1

0
Number1 Number2
1 2
2*2+1=5 1*5=5
5*2+1=11 5*5=25
25*2+1=51 11*5=55
... ...

Every next step uses the result values from the previous line.

why we are doing *2+1 operation on number1 instead of number2? It says Number2 * 2 + 1, Number1 * 5

Number2 has value 2 (on the first line), The expression (for Number1) is Number2 * 2 +1, so: 2 * 2 + 1

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.