Using SQL server, write a while loop to calculate and print the functional value of f(x) = 3x&3 -2X^2 + 15 for all odd non negative integers <= 25. ( 1, 3, 5, …23,25).
This is what I have written out so far
And this is the result I get
So theoretically I should be getting 45,640 when
@x = 25
You have to use
power function like the following
Declare @SUMSQUARE Integer, @x Integer SET @X = 1 WHILE (@X <= 25) BEGIN SELECT @SUMSQUARE = (3*power(@X,3))-(2*power(@X,2))+15 PRINT @SUMSQUARE SET @X = @X + 2 END