Computer Science, asked by BrainlyProgrammer, 1 month ago

New Question!!!

WAP in python/java to print this following series :

I) 23 21 24 19 26 15 28 11 30 7 36...nth term

ii) 4 12 84 3612...nth term
_
Also, write the logic of this series​

Answers

Answered by jhpooja7703
0

Explanation:

I) 23 21 24 19 26 15 28 11 30 7 36...nth term the answer is 5

ii) 4 12 84 3612...nth term the answer is 6526884

Answered by anindyaadhikari13
4

Answer:

Here comes the Python program for this question.

Question 1:

Series: 23 21 24 19 26 15 28 11 30 7 36...N terms

C∅de:

def nextPrime(n):

x=n+1

while True:

 c=sum([1 for i in range(1,x+1) if x%i==0])

 if c==2:

  return x

 x+=1

n,a,b,c=int(input("Enter limit - ")),23,2,-1

for i in range(n):

print(a, end=" ")

a,b,c=a+(b*c),nextPrime(b),-c

Algorithm:

  1. START.
  2. Accept the limit from the user,say n.
  3. Initialise a= 23, b = 2, c = -1
  4. Iterate a loop n times.
  5. Display the value of a.
  6. Add the value of b*c to a.
  7. Find the next prime number and store it in b.
  8. Negate the value of c as prime numbers are added and subtracted.
  9. STOP.

Question 2:

Series: 4 12 84 3612...N terms

C∅de:

n,x=int(input("Enter limit - ")),4

for i in range(n):

print(x,end=" ")

x+=(x*x)//2

Algorithm:

  1. START.
  2. Accept the limit, say n.
  3. Initialise x=4.
  4. Iterate a loop n times.
  5. Display the value of x.
  6. Add the value of int(x²/2) to x and x becomes the next term of the series.
  7. STOP.

See the attachment for output.

Attachments:
Similar questions