File: sqrt.kbs

package info (click to toggle)
basic256 0.9.6.69a-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 26,304 kB
  • sloc: cpp: 7,778; yacc: 926; lex: 575; sh: 21; makefile: 7
file content (29 lines) | stat: -rw-r--r-- 586 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# calculate the square root geometrically (according to Heron)
# Carsten Berndt, 2007

clg
cls
fastgraphics

zuWurzeln=56224
zuZeichnen=zuWurzeln
zweiteZahl=1
delta=0.000001

print "sqrt("; : print zuWurzeln; : print ") =" ;
MainLoop:
  clg
  rect 0, 0, zuZeichnen, zweiteZahl
  zuZeichnen = (zuZeichnen+zweiteZahl)/2
  zweiteZahl  = zuWurzeln/zuZeichnen
  if zuZeichnen-zweiteZahl<delta then print zweiteZahl : goto Ende
  refresh

  pause 1

  goto MainLoop
Ende:
	
print "Check result:";
print zweiteZahl; : print " * "; : print zweiteZahl; : print " = ";
print zweiteZahl*zweiteZahl