# Romatic Numbers with Python

python day 22

Today we will introduce two kinds of interesting number: Narcissistic Number, Perfect Number, and Prime Number.

• Narcissistic Number

numbers that can be represented as the sum of the cube of each digits.

`def nar():    for x in range (1,1001):        s=x%10        t=x//10%10        h=x//100        if x==s**3+t**3+h**3:            print("%d is a narcissistic number" %x)nar()1 is a narcissistic number153 is a narcissistic number370 is a narcissistic number371 is a narcissistic number407 is a narcissistic number1000 is a narcissistic number`
• Perfect Number

the number is equal to its sum of proper divisors.

`from math import sqrtdef perfect(m):    for i in range (1,m):        s=0        for factor in range (1, int(sqrt(i))+1):            if i % factor==0:                s +=factor                if factor >1 and i//factor != factor:                    s+= i//factor        if s==i:            print(i,"is a perfect number" )    print("So you are perfect2!")perfect(10000)1 is a perfect number6 is a perfect number28 is a perfect number496 is a perfect number8128 is a perfect numberSo you are perfect2!`

Once, i thought l is 8128, but now i know, that’s bc he is in C. everything about him has an “i” attached to it.
I just didnt notice/face it back then.
I think i like ppl in R! Keep Real!

• Prime Number

The only divisor of the number is 1 and itself

`from math import sqrtdef prime(m):    for i in range (2,m):        isprime=True        for factor in range (2, int(sqrt(i))+1):            if i % factor ==0:                isprime=False                break        if isprime:            print(i)prime(100)2357111317192329313741434753596167717379838997`

Story time:

Narcissistic flower is daffodil, a handsome boy fell in love with the beauty of himself when he saw himself in the lake.
he became a daffodil so he can look at himself all day long!

Happy studying!

Ref:

https://github.com/jackfrued/Python-100-Days/blob/master/Day01-15/05.%E6%9E%84%E9%80%A0%E7%A8%8B%E5%BA%8F%E9%80%BB%E8%BE%91.md

## More from Miss Discontinuity

Borderline mathematician https://space.bilibili.com/394390651