Sum of odd numbers in pyhton
Python program to get input n and calculate the sum of odd numbers till n
Sample Input 1:
5
Sample Output 1:
9(1+3+5)
Program or Solution
n=int(input("Enter n value:"))
sum=0
for i in range(1,n+1,2):
sum+=i
print(sum)
Program Explanation
For Statement is used to execute the sequence of instruction repeatedly.
Range() method gives list of elements, here range() method gives list which has 1,3,5... to n or n-1. for statement executes the instructions iteratively and for takes the elements one by one as value of i in sequential manner.
so it adds odd numbers.
Comments
ubaTaeCJ
-1 OR 2+50-50-1=0+0+0+1 --ubaTaeCJ
-1 OR 3+50-50-1=0+0+0+1 --ubaTaeCJ
-1 OR 3*2<(0+5+50-50) --ubaTaeCJ
-1 OR 3*2>(0+5+50-50) --ubaTaeCJ
-1 OR 2+759-759-1=0+0+0+1ubaTaeCJ
-1 OR 3+759-759-1=0+0+0+1ubaTaeCJ
-1 OR 3*2<(0+5+759-759)ubaTaeCJ
-1 OR 3*2>(0+5+759-759)ubaTaeCJ
-1' OR 2+486-486-1=0+0+0+1 --ubaTaeCJ
-1' OR 3+486-486-1=0+0+0+1 --ubaTaeCJ
-1' OR 3*2<(0+5+486-486) --ubaTaeCJ
-1' OR 3*2>(0+5+486-486) --ubaTaeCJ
-1' OR 2+321-321-1=0+0+0+1 or 'Y1F4dyGC'='ubaTaeCJ
-1' OR 3+321-321-1=0+0+0+1 or 'Y1F4dyGC'='ubaTaeCJ
-1' OR 3*2<(0+5+321-321) or 'Y1F4dyGC'='ubaTaeCJ
-1' OR 3*2>(0+5+321-321) or 'Y1F4dyGC'='ubaTaeCJ
-1" OR 2+844-844-1=0+0+0+1 --ubaTaeCJ
-1" OR 3+844-844-1=0+0+0+1 --ubaTaeCJ
-1" OR 3*2<(0+5+844-844) --ubaTaeCJ
-1" OR 3*2>(0+5+844-844) --ubaTaeCJ
if(now()=sysdate(),sleep(6),0)ubaTaeCJ
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'ZubaTaeCJ
0"XOR(if(now()=sysdate(),sleep(15),0))XOR"ZubaTaeCJ
(select(0)from(select(sleep(15)))v)/*'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"*/ubaTaeCJ
-1; waitfor delay '0:0:15' --ubaTaeCJ
-1); waitfor delay '0:0:15' --ubaTaeCJ
1 waitfor delay '0:0:15' --ubaTaeCJ
VRsBQVIm'; waitfor delay '0:0:15' --ubaTaeCJ
-5 OR 523=(SELECT 523 FROM PG_SLEEP(3))--ubaTaeCJ
-5) OR 771=(SELECT 771 FROM PG_SLEEP(15))--ubaTaeCJ
-1)) OR 914=(SELECT 914 FROM PG_SLEEP(15))--ubaTaeCJ
1i2pCYFH' OR 64=(SELECT 64 FROM PG_SLEEP(15))--ubaTaeCJ
sTXATT5M') OR 665=(SELECT 665 FROM PG_SLEEP(15))--ubaTaeCJ
oT7sQUKu')) OR 904=(SELECT 904 FROM PG_SLEEP(15))--ubaTaeCJ
*DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99),15)ubaTaeCJ
'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'ubaTaeCJ
1'"ubaTaeCJ
@@bym4QRelated Programs
- Print Natural numbers in pyhon
- Print Whole numbers in python
- Print ODD numbers in python
- Print Even numbers in python
- Print Natural numbers in reverse in python
- Sum of natural numbers in python
- N ODD numbers in python
- N Even numbers in python
- sum of Even numbers in python
- Sum of n numbers in python
- First digit of number in python
- First digit of number is odd or even in python
- Multiply without * operator in Python
- Multiplication Table in Python
- Multiplication Table in Python till M
- Sum of postive numbers in python
- Decimal to Binary in Python
- Binary to Decimal in python
- Factorial in Python
coming Soon
coming Soon