Problem Euler 26

kinuthiA muchanE muchanek at
Wed Jul 2 17:37:24 BST 2008


Andrew, this is hideous, really trivial! Here we go:

from decimal import Decimal,getcontext # import the module because it is
not a standard module
getcontext().prec = 1000 # set the precision to 1000 places
a = Decimal("1") # the argument passed to the Decimal function has to be
a string 
h=983 # the guess!
b = Decimal(str(h)) # convert it  into a string
abStr = str(a/b)[2:] # slice the string to remove "0."

print abStr

I am sure you will find far, far erudite codes in all languages in the
thread for that question. Apparently, there is an known algorithm for
solving this particular problem, but do I say. But it seems I was not
alone in using bush logic in trying to solve the problem!!

As you might already know, python is a dynamically typed language( some
really pedantic types will also add strongly typed, because you cannot
use an integer as a string without converting it first, something you
can in a language like VB Script!!), you do not declare the data-types
of variables (like in C and Java), just assign values to variables and
off you go! You do not need even the $ sign to identify your variables
like Perl or php. They say python is very user friendly and at the same
time very powerful, and undoubtedly very readable. 

You can subscribe to the mailing list here:

By the way, Andrew, Miano how many problems have you solved on Project
Euler? I have solved a measly 33.


More information about the Ubuntu-ke mailing list