Computer Science, asked by BrainlyProgrammer, 2 months ago

New Question!!

WAP to print the following series
 \texttt{15  156 1563 15636 ... nth term}

Answers

Answered by atrs7391
6

number = 15

n_term = int(input("Enter nTH Term: "))

loop_controller = 0

while loop_controller <= n_term:

   print(number, end=" ")

   number = (number*10)+6

   loop_controller = loop_controller + 1

   if loop_controller == n_term:

       break

   print(number, end=" ")

   number = (number*10)+3

   loop_controller = loop_controller + 1

   if loop_controller == n_term:

       break

Answered by anindyaadhikari13
4

Answer:

The given co‎de is written in Python.

a,b,n=15,6,int(input("Enter limit - "))

for i in range(n):

   print(a,end=" ")

   a=a*10+b

   b=3 if b==6 else 6

Algorithm:

  • Start program.
  • Accepting the limit.
  • Initializing a = 15, b = 6
  • Loop i = 0 to n-1:
  •   Display the value of a
  •   Multiply a by 10 and add b to it.
  •   Change b to 3 if b is 6 or else 6.
  • End loop.
  • End program.

See the attachment for output.

•••♪

Attachments:
Similar questions