Page 504 - ComputerScience_Class_11
P. 504
Program 2: Write a program to check if a number is a pronic number or not. Pronic number is a number which is a
product of two consecutive integers, that is, n(n + 1).
Example: 12 = 3 × 4
Program 2.py
File Edit Format Run Options Window Help
n=int(input('Enter a number: '))
f=False
for i in range(1,n):
if i*(i+1)==n:
f=True
break
if f:
print(n,'is a pronic number')
else:
print(n,'is not a pronic number')
Output
Enter a number: 20
20 is a pronic number
Program 3: Write a program to enter any number and check if it is a magic number or not. If the ultimate sum of digits
of the number is equal to 1 then it is called magic number.
Example: 100 1+0+0=1 So 100 is a magic number
Program 3.py
File Edit Format Run Options Window Help
n=int(input('Enter a number: '))
c=n
while c>9:
s=0
while c>0:
d=c%10
s=s+d
c=c//10
c=s
if c==1:
print(n,' is a magic number')
else:
print(n,'is not a magic number')
Output
Enter a number: 289
289 is a magic number
502 Touchpad Computer Science (Ver. 3.0)-XI

