Answer:
- import sys
-
- def fibonacci(n):
- if(n == 0 or n == 1):
- return n
- else:
- return fibonacci(n - 2) + fibonacci(n-1)
-
- num = int(sys.argv)
- output = ""
-
- for i in range(1, num+1):
- output += str(fibonacci(i)) + " "
-
- print(output)
Explanation:
Firstly, we import sys module as we need to accepts n as command line argument (Line 1).
Next, create a function fibonacci takes take one input n (Line 3). If the n is zero or one, return the n itself (Line 4-5). Otherwise, the program shall run the recursive call to the fibonacci function itself by putting n-2 and n-1 as function argument, respectively (Line 6-7).
After that, use the sys.argv to get the command line argument and assign the value to num (Line 9).
Use a for loop to generate the output string by progressively calling the fibonacci function and join the return result to the output string (Line 12-13).
At last print the output string (Line 15).
Answer:
Explanation:
The following code is written in Python. It creates a for loop that iterates 10 times, asking the user for a number every time. It then checks if the number is inside the numArray. If it is not, then it adds it to the array, if it is then it skips to the next iteration. Finally, it prints the number of distinct numbers and the list of numbers.
numArray = []
for x in range(10):
num = input("Enter a number")
if int(num) not in numArray:
numArray.append(int(num))
print("Number of Distince: " + str(len(numArray)))
for num in numArray:
print(str(num), end = " ")
Answer and Explanation:
Digest authentication :
Digest authentication is a technique of authentication in which a request from potential client is received by a system server and after that sent to a space controller.
How it is work :
Digest authentication averts replay assaults by utilizing a server-indicated nonce. The server produces an irregular nonce when the customer endeavors to make an unauthenticated demand, customer needs to join the nonce into its reaction. It's dependent upon the server to oversee substantial nonces, and nullify them when they've been utilized, to anticipate replays