We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
import decimal
num=decimal.Decimal(int(input()))
dot100 = decimal.Context(prec=10000)
num=num.sqrt(dot100)
num=str(num)
precision=int(input())
sum1=x=i=0
while num[i]!=".":
i=i+1
num=num[:i]+num[i+1:]
num=num[0:precision]
print(sum([int(x) for x in num]))
this is my code
i am passing only the first test condition
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Join us
Create a HackerRank account
Be part of a 26 million-strong community of developers
Please signup or login in order to view this challenge
Project Euler #80: Square root digital expansion
You are viewing a single comment's thread. Return to all comments →
import decimal num=decimal.Decimal(int(input())) dot100 = decimal.Context(prec=10000) num=num.sqrt(dot100) num=str(num) precision=int(input()) sum1=x=i=0 while num[i]!=".": i=i+1 num=num[:i]+num[i+1:] num=num[0:precision] print(sum([int(x) for x in num]))
this is my code i am passing only the first test condition