Write a SQL Program to print out the first 10 numbers of the
following sequence F(n).
F(1) = 3, F(2)=5. F(n)=3*F(n-1) –2*F(n-2).
E.g., F(3) = 3*F(2) – 2* F(1) = 3*5–2*3=15-6=9
Your program will print out F(1), F(2),..., F(10).
Hint: use three variables, the first storing F(n), the second storing F(n-1), and the third storing F(n-2). Think of how to compute the first variable from the other two and how to update the other two variables in each iteration
declare
-- declare variable first = 3,
-- second = 5 and temp of datatype number
first number := 3;
second number := 5;
temp number;
n number := 10;
i number;
begin
dbms_output.put_line('Series:');
--print first two term first and second
dbms_output.put_line(first);
dbms_output.put_line(second);
-- loop i = 2 to n
for i in 2..n
loop
temp:=3*second-2*first;
first := second;
second := temp;
--print terms of fibonacci series
dbms_output.put_line(temp);
end loop;
end;
--Program End
Write a SQL Program to print out the first 10 numbers of the following sequence F(n)....
The sequence of the first twelve Lucas numbers is:
2,1,3,4,7,11,18,29,47 …
Please write a program for calculating the Lucas number
Ln given the number n. Print out the
results given:
a) n=2 ; b) n=5 and c) n=10
(**please answer in Python**)
Ln 2 1 (Ln-1 + Ln-2 if n= 0 if n = 1 if n >1
In Python! Create the program that print out only odd numbers 1,3,5,7,9 Use either a while loop or a for loop to print only odd numbers 1, 3, 5, 7, 9 *tip: you can use range () function, or a condition with ‘break’ (e.g, while count < 10) In python!: Create a program that print out 12 months of a year and associated numbers (e.g., January 1, February 2…). Two lists should be created, and then loop through the list...
Write a program that generates 2n Fibinacci numbers. the following is a sequence of Fibinacci numbers: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89... (Starting from the third number, the number is the sum of the previous two numbers.)
Please answere using python language codes. Write a program to print out Collatz sequence for a user-supplied number. Prompt the user for a positive integer which will become the first number in the sequence. Next number in the sequence is derived as follows: If previous number is odd, the next number is 3 times the previous, plus 1. If previous number is even, the next number is half of the previous According to Collatz proposition, the sequence ultimately reaches 1...
Write a java program that will print if n numbers that the user will input are or not within a range of numbers. For that, your program needs to ask first for an integer number called N that will represent the number of times that will ask for other integer numbers. Right after, it should ask for two numbers that will represent the Min and Max for a range. Lastly. it will iterate N number times asking for an integer...
Write a complete C program that generate the following sequence of numbers in two ways. First, the sequence of numbers should be made using a WHILE LOOP, then a DO-WHILE LOOP. 19, 15, 11, 7, 3, -1, -5, -9
The Fibonacci sequence is the sequence of numbers: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, … The next number is found by adding up the two numbers before it. For example, the 2 is found by adding the two numbers before it (1+1). The 3 is found by adding the two numbers before it (1+2). The 5 is found by adding the two numbers before it (2+3), and so on! Each number in the sequence is called...
A Fibonacci sequence is a series of numbers where the next number in the series is the sum of the previous two numbers. The sequence starts with the numbers 0 and 1. Here are the first ten numbers of the Fibonacci sequence: 0 1 1 2 3 5 8 13 21 34 Write a Java program to print out the first fifteen numbers of the Fibonacci sequence using a loop. You will need three variables previous, current, and next...
Write a Python program (using a nested loop) to print out the following pattern (there is a space between the numbers next to each other). 1 2 1 3 2 1 4 3 2 1 5 4 3 2 1
(Print distinct numbers) C++ Write a program that reads in 10 numbers and displays distinct numbers (i.e., if a number appears multiple times, it is displayed only once). The numbers are displayed in the order of their input and separated by exactly one space. (Hint: Read a number and store it to an array if it is new. If the number is already in the array, discard it. After the input, the array contains the distinct numbers.) Sample Run Enter...