Home > Problem, Projects/Experiments, Python > Python: Champernowne’s constant

Python: Champernowne’s constant



Python: Champernowne’s constant
Problem No.40 @ ProjectEuler
Completed on: Mon, 1 Jul 2019, 18:01

In This task No.40, basically we need to get some digits from a large decimal fraction, then finding the multiplication of those digits.

ProjectEuler assume that the fraction is: 0.123456789101112131415161718192021222324 …. until 1000000, then we should fined the digits in positions 1, and 10, 100, 1000, 10000, 100000 and 1000000. Here is a copy of the problem screen


So to solve this I create a string variable n_list then using for loop i store the numbers from 1 to 1000000 in it as [12345678910111213141516 … 1000000], and simply get the digits I want using the list index, and Finally I calculate the needed multiplication as required. .. And we solve it. ..




Follow me on Twitter..



Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: