Home > other >  Calculation of the output of Yang hui triangle any position value
Calculation of the output of Yang hui triangle any position value

Time:11-29

Beginners PYthon, after-school numerical calculating output of Yang hui triangle any position, such as line 100000, 999, computation time is about 0.021 seconds, posted to share with you the
From the time the import *
A=int (input (" please input line number: "))
B=int (input (" please enter the same which: "))
While b & gt; A:
B=int (input (" digits is not greater than the line Numbers, please re-enter the same ranked: "))
Ks=time ()
If a & lt;=2/b or b====1:
Print (" first "+ STR +" first "+ STR (a) (b) +" digits is: 1)
Elif b==2 or b==1:
Print (" first "+ STR +" first "+ STR (a) (b) +" digits is: "+ STR (a - 1))
The else:
N=a - b + 1
X=n * (n + 1)
Y=1
For I in range (2 b) :
If I & lt; B - 1:
X=x * (n + I)
Y=y * I
The else:
Y=y * I
Print (" first "+ STR +" first "+ STR (a) (b) +" digits is: "+ STR (x/y))
Print (time () - ks)
  • Related