We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2
Write a program to find sum of the series :s=1+x+x´ +x...
+x" (Input the values of xand n
28. Solution. X = float (input ( "Enter value of x:" )) n= int (input( "Enter value of n (for x ** n) :" )) S =0
for a in range (n + 1) : S += X ** a
print ("Sum of first" , n, "terms :", s)
275 cubes a reversed initially !") number!") number") an ")) number") is palindrome!") is Number.) palindrome numberthe number: number number") number! of number's num palindrome! sum PerfectPerfect Armstrong Armstrong given number:")) given the digit number.)stores Armstrong 407 a Perfect to a not a a a equal numbera "is "is not if 3 number: if palindromenumber "is is not. an check is a an check not. num, a n, is number ("Enter the ("Enter num, not " a or it Not Armstrong Enter number:67826 Summ + 1 n, Enter number", number: 28 to number then 10 **3 an or to number as working dig10 ("Number", ("Number", n): number",is program 0): % "is "is digit program Summ): 10 is 28 digitdigit, same (input > + // while(wnum 0): 0): range(1, int(input tempdigit (A % rev*10rev): 67826 n): number Ifa3 > temp //= 10 (num, print(num, wnum wnum ("The print("The Armstrong (temp 3 an is palindrome # Summ each num = += Solution. temp = == Solution. i % a Write (Note. Sümm =0 digit Summ (numprint a is a numberint num = = = = print print Number in if(n 1f (summ print its while Enter Write dig rev wnum (num The = num else: 407 = = else: i else: of 1f numwnum =rev for 32. if 33. and and a which 3.466666666666667 n ")) n ")) is and "terms :", S) and S) number (input("Enter ofx:")) (n): "))(n): integer, x x x: : of power of power added )/f "terms given value value of nnber positive value 521 value : sign divisors.) number:) 4!* 3!21 w theseries C CONTROL OFFLOW 1-+*-x+rt. the sign n, first", the theterm 1): a+1) n, a input (input("Enter : 1) 4 terms: series: 5 : if a (n): check is its tnput ("Enter ("Enter first + * first", + *a) 5 (n): range(1, eaprogran tto the (n range* X: to the n range(2, a)) ** S += term 4 x: terms power to ot. of sum Enter of stum (X term += =-1of("Sum S signprint of power 4 program (input # (input ((x sign of of *=1 5 programor of the Solution. int 1sign = in term lue first va the suM sign = +1 in in *=i i = ("Sum value first number Note. A perfect the (" int a int Solution.int for f term f=1 the to int(input a the cint n= for Enter Enterof Write print x=n= =X for a equalSolution. print EnterEnterof a perfect Sum Dun Write S 15 1 L