Eularproject 32: Number 1-9 permutations constitute multiplication equation

Source: Internet
Author: User

Pandigital Products
Problem 32
We shall say that a n-digit number is pandigital if it makes use of the the digits 1 to n exactly once; For example, the 5-digit number, 15234, is 1 through 5 pandigital.

The product 7254 is unusual, as the identity, 39x186 = 7254, containing multiplicand, multiplier, and product is 1 Throu GH 9 pandigital.

Find the sum of whose multiplicand/multiplier/product identity can be written as a 1 through 9 pandigital.

Hint:some products can is obtained in more than one-to-one-to-so is sure to only include it once in your sum.

Answer:
45228
Completed on Sat, Jul 2015, 15:13
Python code:

 fromMathImportsqrt def func(x):S0=set (str (x)) forIinchRange2, Min ( -, int (sqrt (x) +1))):ifx%i==0: S1=set (str (i)) S2=set (str (x//i)) s=s0|s1|s2ifLen (s) = =9  and ' 0 '  not inchSreturn True    return Falseresult=0 forIinchRange +,9999): Pstr=str (i)ifLen (Set (Pstr)) = =4  and ' 0 '  not inchPSTR:ifFunc (i): Result+=i print (i) print (result)

Because the requirements of the product can not be repeated, it is possible to consider the product candidate cycle judgment, the addition of satisfying conditions, and it is easy to disprove the proof that the product number of digits can only be 4.

The number 1-9 is an interesting question, and more questions can be referred to
Http://www.worldofnumbers.com/ninedig1.htm

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Eularproject 32: Number 1-9 permutations constitute multiplication equation

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.