I could not understand this question for practicing python [closed] - python-3.x

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 10 months ago.
Improve this question
Could anyone please help me in understanding the question for this.
I got this from https://www.geeksforgeeks.org/python-program-for-nth-multiple-of-a-number-in-fibonacci-series/
Given two integers n and k. Find position the n\’th multiple of K in the Fibonacci series.
Examples:
Input : k = 2, n = 3
Output : 9
3'rd multiple of 2 in Fibonacci Series is 34
which appears at position 9.
Input : k = 4, n = 5
Output : 30
5'th multiple of 5 in Fibonacci Series is 832040
which appears at position 30.

You are interested in the numbers that are divisible by k in the fibonacci sequence. Among these numbers, you seek the index of the nth, that is, the index i such that the ith fibonacci number is divisible by k, and such that there are exactly n-1 fibonacci numbers before that one that are also divisible by k.

Related

How Do I Calculate The Difference of Each Element in A List (Python) [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I'm new to Python and I wanted to know that how can I subtract All the Elements in A List in Python
For Eg -
list [5,6,7,8,9]
I want to subtract it like this = 5 - 6 - 7 - 8 - 9
Use reduce, which expands out to subtracting all elements.
>>> from functools import reduce
>>> reduce(lambda x, y: x - y, [5,6,7,8,9])
-25
To subtract each number from the first one, you can subtract the sum of them:
>>> mylist = [5,6,7,8,9]
>>> print(mylist[0] - sum(mylist[1:]))
-25

Write a program to compute the sum of all divisors of positive integer input n. Using Python [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
Write a program to compute the sum of all divisors of positive integer input n.
input example: a positive integer 10
output:1+2+5+10=18
def factor(n): if n==0: return[0] if n<=3: return[1] x=n list=[1] i=2 while i<=x: if x%i==0: if i !=list[-1]: list.append(i) x=x//i i=2 continue i+=1
Try this
n=int(input("Enter an integer:"))
print("The sum of all divisors of given positive integer input is:")
sum = 0
for i in range(1,n+1):
if(n%i==0):
sum = sum + i
print(sum)
Enter an integer:36
The sum of all divisors of given positive integer input is:
91
Hope this will be of your help.

how much string that length is n can we create from A and B that string will not contain two A consecutively [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
how much string that length is n can we create from A and B that string will not contain two A consecutively.
For example;
if n=1 , strings are A ve B => it has 2 solutions
if n=2 , strings are AB, BA, BB => it has 3 solutions
in n=3 , strings are ABB, ABA, BAB, BBA, BBB => it has 5 solutions ... etc.
I need a decrease and conquer algorithm , can you help me please ?
if n=1, result[1] = 2
if n=2, result[2] = 3
if n=3, result[3] = 5
if n=4, result[4] = 8
if n=5, result[5] = 13
so, this generates a Fibonacci sequence.
result[1] = 2
result[2] = 3
result[n] = result[n-1]+result[n-2];
Closed form of Fibonacci sequence:

compute Average in Bash [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Problem Statement
Given N integers, compute their average, correct to three decimal places.
Input Format
The first line contains an integer N.
This is followed by N integers, each on a new line.
Output Format
Display the average of the N integers, rounded off to three decimal places.
Input Constraints
1 <= N <= 500
-10000 <= x <= 10000 (x refers to elements of the list of integers for which the average is to be computed)
Sample Input
4
1
2
9
8
Sample Output
5.000
explaination
The '4' in the first line indicates that there are four integers whose average is to be computed. The average = (1 + 2 + 9 + 8)/4 = 20/4 = 5.000 (correct to three decimal places) Please include the zeroes even if they are redundant (eg. 0.000 instead of 0).
You can use this awk command:
awk 'NR==1{n=$1;next} {s+=$1} END{printf "%.3f\n", s/n}' file
5.000

frequency of letters at position in string [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to count the frequency of 4 letters at every position across strings. The letters are A, T, G, C
TGAGGTAGTAGTTTGTGCTGTTAT
TAGTAGTTTGTGCTGTTA
TGAGGTAGTAGTTTGTAC
TGAGAACTGAATTCCATAGG
desired output:
Pos1 Pos2 Pos3 and so on.
A 0 1
T 4 0
C 0 0
G 0 3
So far I have used an R package called Biostrings, which works, but I wonder if perl would do this?
For the record, for
x = "TGAGGTAGTAGTTTGTGCTGTTAT
TAGTAGTTTGTGCTGTTA
TGAGGTAGTAGTTTGTAC
TGAGAACTGAATTCCATAGG"
a Biostrings solution is
library(Biostrings)
consensusMatrix(DNAStringSet(strsplit(x, "\n")[[1]]))
which will be fast for millions of sequences.

Resources