Python3 to achieve the isomorphism number of less than 10000 __python

Source: Internet
Author: User

Problem: The number of square-low lows is exactly equal to the number of isomorphism numbers. Ask for all isomorphism numbers less than 10000.

Compilation environment: Python3 + Spyder

The general code is as follows:

For I in range (10000):
   k = str (i * i)                            #平方数
    if (len (k)% 2 = 0):
        m = Int (k[(len (k)//2): Len (k)])     #取后位数
        if (m = = i):
            print (m,end= "")
    else:
        m = Int (k[(len (k) + 1)//2)-1:len (k)])
        if (m = = i):
            print (m,end= "")

after using the list resolution:

From the math import ceil
print ([I for I in range (1,10000) for n in range (len (str (i * i)), Len (str (i * i)) + 1) If i = = I * I% (10** (ceil (N/2))])

Operation Result:

[1, 5, 6, 25, 76, 376, 625, 9376]




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.