First power of 2 that has leading decimal digits of 12: Difference between revisions
Content deleted Content added
Thundergnat (talk | contribs) m →{{header|C#}}: Regularize header markup to recommended on category page |
First power of 2 that has leading decimal digits of 12 in BASIC256 |
||
Line 124:
p(123, 678910) = 193,060,223
</pre>
=={{header|BASIC256}}==
<lang BASIC256>global FAC
FAC = 0.30102999566398119521373889472449302677
print p(12, 1)
print p(12, 2)
print p(123, 45)
print p(123, 12345)
print p(123, 678910)
end
function p(L, n)
cont = 0 : j = 0
LS = string(L)
while cont < n
j += 1
x = FAC * j
if x < length(LS) then continue while
y = 10^(x-int(x))
y *= 10^length(LS)
digits = string(y)
if left(digits,length(LS)) = LS then cont += 1
end while
return j
end function</lang>
{{out}}
<pre>Same as FreeBASIC entry.</pre>
=={{header|C}}==
|