clg
font "arial",10,100
Dim note(50)
Dim time(50)
note={0,0,7,7,9,9,7,5,5,4,4,2,2,0,7,7,5,5,4,4,2,7,7,5,5,4,4,2,-1,-1,7,7,9,9,7,5,5,4,4,2,2,0}
time={1,1,1,1,1,1,2,1,1,1,1,1,1,2,1,1,1,1,1,1,2,1,1,1,1,1,1,2,1 ,1 ,1,1,1,1,2,1,1,1,1,1,1,2}
outoftune=0
for n = 0 to 12
text 0,494-262*2^(n/12),int(262*2^(n/12))+"hz"
line 30,500-262*2^(n/12),300,500-262*2^(n/12)
next n
for a = 0 to 49
f=1+outoftune*(rand-0.5)
hz=f*262*2^(note[a]/12)
sound hz,time[a]*200
rect 40+a*5,297-(hz-200),time[a]*4,7
next a
Sunday, October 31, 2010
Thursday, October 28, 2010
Combined events
fastgraphics : Dim a(5):Dim c(5)
Dim list(30)
font "arial",10,100
clg
For n = 1 to 4
a[n]=int(rand*8+1) : c[n]=int(rand*8+1)
next n
for draw = 1 to 600
x=int(rand*4+1): z=int(rand*4+1)
color red
rect x*20,20,15,15
color green
rect z*20+200,20,15,15
color black
For n = 1 to 4
text n*20,20,a[n]
text n*20+200,20, c[n]
next n
Print a[x] + "+" +c[z]+ "="+(a[x]+c[z])
list[a[x]+c[z]]=list[a[x]+c[z]]+1
For w = 2 to 18
text 15,14*w+10,w
rect 35,14*w+12,list[w]*2,10
next w
if draw = 3 then input "Wich sum is more frequent " , a$
refresh
pause 2/draw
clg
next draw
Dim list(30)
font "arial",10,100
clg
For n = 1 to 4
a[n]=int(rand*8+1) : c[n]=int(rand*8+1)
next n
for draw = 1 to 600
x=int(rand*4+1): z=int(rand*4+1)
color red
rect x*20,20,15,15
color green
rect z*20+200,20,15,15
color black
For n = 1 to 4
text n*20,20,a[n]
text n*20+200,20, c[n]
next n
Print a[x] + "+" +c[z]+ "="+(a[x]+c[z])
list[a[x]+c[z]]=list[a[x]+c[z]]+1
For w = 2 to 18
text 15,14*w+10,w
rect 35,14*w+12,list[w]*2,10
next w
if draw = 3 then input "Wich sum is more frequent " , a$
refresh
pause 2/draw
clg
next draw
Wednesday, October 27, 2010
Force and Drag
clg
fastgraphics
rem Initial variables
speed = 0:density=1.2 : area=2:pullforce=1000
mass=1400: dist =0 :time=0 :dragcoef=.35
dt=0.005 : c=0
font "arial",15,15
while speed<200
drag=0.5*density*speed^2*area*dragcoef
acc=((pullforce-drag)/mass)*dt
clg
speed = speed + acc
dist = dist + (speed)*dt
time = time + dt
text 10,10 ,"Time "+int(time)+" sec"
text 10,30, "Speed "+int(speed)+"m/s "+int(speed*3.6)+"km/h"
text 10,50 ,"Distance "+int(dist)+"m"
text 10,70 ,"Acceleration "+((pullforce-drag)/mass)+"m/s^2"
text 10,90 ,"Work "+int(dist*pullforce/1000)+" kj"
text 10,110 ,"Power "+int(speed*pullforce/1000)+" kw "+int(speed*pullforce/750)+"hp"
c=c + (speed)*dt
text 150,220," |''''''|'''''''|''''\"
text 150,235," |''''''|'''''''|'''''o"
text 150,250," '-(0)---(0)='"
text 1-c,255,"......................................."+(dist-c)+"m .............................................................."
if 150-c<0 then c=c-150
refresh
end while
Tuesday, October 26, 2010
Force and Friction
clg
fastgraphics
rem Initial variables
speed = 0:pullforce=500
mass=40: dist =0 :time=0 :frictioncoef=.5
dt=0.005 : c=0 : fforce=mass*9.81*frictioncoef
acc=((pullforce-fforce)/mass)*dt
while time<30
clg
if pullforce > fforce then speed = speed + acc
dist = dist + (speed)*dt
time = time + dt
text 10,10 ,"Time "+time+" sec"
text 10,20, "Speed "+speed+"m/s"
text 10,30 ,"Distance "+int(dist)+"m"
text 10,40 ,"Acceleration "+((pullforce-fforce)/mass)+"m/s^2"
text 130,120 ,"Mass "+mass+"Kg"
text 10,140 ,fforce+" N <---Friction ---------------------------Pull--->"+pullforce+" N"
rect 120,145,60,20
c=c + (speed)*dt
text 1-c,155,"......................................."+(dist-c)+"m .............................................................."
if 150-c<0 then c=c-150
refresh
end while
fastgraphics
rem Initial variables
speed = 0:pullforce=500
mass=40: dist =0 :time=0 :frictioncoef=.5
dt=0.005 : c=0 : fforce=mass*9.81*frictioncoef
acc=((pullforce-fforce)/mass)*dt
while time<30
clg
if pullforce > fforce then speed = speed + acc
dist = dist + (speed)*dt
time = time + dt
text 10,10 ,"Time "+time+" sec"
text 10,20, "Speed "+speed+"m/s"
text 10,30 ,"Distance "+int(dist)+"m"
text 10,40 ,"Acceleration "+((pullforce-fforce)/mass)+"m/s^2"
text 130,120 ,"Mass "+mass+"Kg"
text 10,140 ,fforce+" N <---Friction ---------------------------Pull--->"+pullforce+" N"
rect 120,145,60,20
c=c + (speed)*dt
text 1-c,155,"......................................."+(dist-c)+"m .............................................................."
if 150-c<0 then c=c-150
refresh
end while
Sunday, October 24, 2010
Linear colisions
fastgraphics
m1=4 : v1=10 :p1=57
m2=20 : v2=0 : p2=150
elast=.5
font "arial",15,15
While abs(p1-150)<151 and abs(p2-150)<151
clg
Text 0,10,"Pos1= "+int(p1)
Text 130,10,"Vel1= "+v1
Text 0,40,"Pos2="+int(p2)
Text 130,40,"Vel2="+v2
circle p1,150,m1
circle p2,150,m2
refresh
p1=p1+v1
p2=p2+v2
if abs(p1-p2)<=m1+m2 then
v11=v1
v1=(elast*m2*(v2-v1)+m1*v1+m2*v2)/(m1+m2)
v2=(elast*m1*(v11-v2)+m1*v11+m2*v2)/(m1+m2)
end if
pause.05
end while
Saturday, October 23, 2010
Bubble sort
fastgraphics : Dim a(32): flag=1
For n = 1 to 30
a[n]=int(rand*20+1)
next n
while flag=1
flag=0
For n = 1 to 30
clg
For w = 1 to 30
text 15,10*w,a[w]
rect 40,10*w,a[w]*10,7
next w
pause .01
refresh
if a[n]> a[n+1] then
x=a[n]
a[n]=a[n+1]
a[n+1]=x
flag=1
end if
next n
end while
For n = 1 to 30
a[n]=int(rand*20+1)
next n
while flag=1
flag=0
For n = 1 to 30
clg
For w = 1 to 30
text 15,10*w,a[w]
rect 40,10*w,a[w]*10,7
next w
pause .01
refresh
if a[n]> a[n+1] then
x=a[n]
a[n]=a[n+1]
a[n+1]=x
flag=1
end if
next n
end while
Friday, October 22, 2010
Binomial Distribution
clg
Dim p(300)
for z=0 to 100000
sum =0
for n = 1 to 300
if int(rand*2)=1 then sum=sum+1
next n
rect sum,300-p[sum],1,300
p[sum]=p[sum]+1
next z
Dim p(300)
for z=0 to 100000
sum =0
for n = 1 to 300
if int(rand*2)=1 then sum=sum+1
next n
rect sum,300-p[sum],1,300
p[sum]=p[sum]+1
next z
Saturday, October 16, 2010
Adding Fractions
clg
a=int(rand*5+2)
b=int(rand*5)+a
c=int(rand*2+1)
d=int(rand*5+1)+c
Print a+" + "+c
Print b+" "+d
w=170 : k=0 : gosub lines
for n = 0 to 400
circle rand*130*(a/b),rand*130,1
circle rand*130+170,rand*130*(c/d),1
next n
input "Press enter for the answer", a$
w=0 : k=169 : gosub lines
Print "="+(a*d+c*b)+"/"+b*d
lines:
for n = 0 to 130 step 130/b
line n+k,0,n+k,130
next n
for n = 0 to 130 step 130/d
line 0+w,n,130+w,n
next n
return
Multiplying Fractions
clg
a=int(rand*5+1)
b=int(rand*5)+a
c=int(rand*5+1)
d=int(rand*5+1)+c
Print a+" X "+c
Print b+" "+d
for n = 0 to 299 step 299/b
line n,0,n,299
next n
for n = 0 to 500
circle rand*300*(a/b),rand*300,2
next n
for n = 0 to 299 step 299/d
line 0,n,299,n
next n
for n = 0 to 1500
circle rand*300*(a/b),rand*300*(c/d),2
next n
Friday, October 15, 2010
Projectile
clg
fastgraphics
rem Initial variables
speed = 70 :gravity = 9.81
angle=70: height=0 :h1=0 :distance=0
t=0:dt=0.005
angle=pi*angle/180
hspeed = speed*cos(angle)
vspeed = speed*sin(angle)
while height>=h1
clg
t=t+dt : h1=height
vspeed = vspeed - gravity*dt
height = height + vspeed*dt
distance = distance + hspeed*dt
circle distance,300-height,3
text 10,10 ,"Time "+t
text 10,20, "Height "+height
text 10,30 ,"Distance "+distance
refresh
end while
fastgraphics
rem Initial variables
speed = 70 :gravity = 9.81
angle=70: height=0 :h1=0 :distance=0
t=0:dt=0.005
angle=pi*angle/180
hspeed = speed*cos(angle)
vspeed = speed*sin(angle)
while height>=h1
clg
t=t+dt : h1=height
vspeed = vspeed - gravity*dt
height = height + vspeed*dt
distance = distance + hspeed*dt
circle distance,300-height,3
text 10,10 ,"Time "+t
text 10,20, "Height "+height
text 10,30 ,"Distance "+distance
refresh
end while
Wednesday, October 13, 2010
Inequalities
clg
rem generate graph
for y = -5 to 5 : for x = -5 to 5
circle int(30*x)+150, int(30*y)+ 150,3
next x : next y
line 150,0,150,300 : line 0,150,300,150
rem generate lines
color red
m1=int(rand*8-4)/(int(rand*4+1)): c1=int(rand*8-4)
m2=int(rand*8-4)/(int(rand*4+1)): c2=int(rand*8-4)
for x = -5 to 5 step .02
y1 = m1*x+c1
y2 = m2*x+c2
circle 30*x +150, 150 - 30*y1,1
circle 30*x +150, 150 - 30*y2,1
next x
rem generate shade
for n = 1 to 5000
x=rand*10-5
y=rand*10-5
if y > m1*x+c1 and y < m2*x+c2 then
circle 30*x +150, 150 - 30*y,1
end if
next n
input "The area is defined by",a$
print "y>"+m1+"x"+"+"+c1
print
print "y<"+m2+"x"+"+"+c2
input "The area is defined by",a$
print "y>"+m1+"x"+"+"+c1
print "y<"+m2+"x"+"+"+c2
Tuesday, October 12, 2010
HCF
a=420
b=360
c= int ((a+b)/2)
loop:
if a/c = int (a/c) and b/c = int (b/c) then
print "The highest common factor to a and b is "+ c
end
end if
c=c-1
goto loop
Prime factorization
for m=2 to 1000
n=m
print n+"=";
for f = 2 to n
if n/f = int (n/f) then
n=n/f
print f+"x";
f=f-1
end if
next f
print
next m
n=m
print n+"=";
for f = 2 to n
if n/f = int (n/f) then
n=n/f
print f+"x";
f=f-1
end if
next f
next m
Monday, October 11, 2010
Sunday, October 10, 2010
Compound interest
clg
color red
value=10
f=150/value
intrest=2
for y = 1 to 40
value=value*(1+intrest/100)
print y+" "+value
rect y*5 ,300-value*f,4,value*f
next y
color red
value=10
f=150/value
intrest=2
for y = 1 to 40
value=value*(1+intrest/100)
print y+" "+value
rect y*5 ,300-value*f,4,value*f
next y
Mandala
clg
x1=80
y1=70
d =200
angle = 90
for s = 1 to 200
gosub lines
angle = angle + 111
next s
lines:
r = (angle/180)*3.14159
y2=y1 + (sin (r))*d
x2=x1 - (cos (r))*d
line x1,y1,x2,y2
x1=x2
y1=y2
return
Friday, October 8, 2010
Abundant numbers
Rem Abundant numbers are smaller than the sum of their factors
for n = 5 to 100000
sum = 0
for factor = 1 to int(n/2)
if n/factor = int(n/factor) then sum = sum + factor
next factor
if sum > n then print n
next n
for n = 5 to 100000
sum = 0
for factor = 1 to int(n/2)
if n/factor = int(n/factor) then sum = sum + factor
next factor
if sum > n then print n
next n
Wednesday, October 6, 2010
Pi by chance
clg
in=0
color red
circle 150,150,150
color black
For dots = 1 to 10000
x=rand*300+1
y=rand*300+1
circle x,y,2
if ((x-150)^2+(y-150)^2)^.5<=150 then in=in+1
print in*4/dots
next dots
Prime number finder
clg
f=0
for h = 3 to 10000 step 1
if f=0 then print h-1
f=0
for i = 2 to int(h/2)+1 step 1
if int(h/i)=h/i then f=1
if int(h/i)=h/i then i=h/2
next i
next h
20 and out
rem add 1,2, or 3 . The first to get to 20 loses
clg
font "arial",10,100
total=0 : n=1 : Sq=3
play:
input"How much add 1-3? ",a$
a=int(a$): total=total+a
if Sq<=total then
n=n+1
Sq=4*n-1
endif
if Sq-total < 4 then
p=Sq-total
w=1
else
p=int(rand*2)+1
w=0
endif
total=total+p
for c = total-a-p+1 to total-p
color red
circle 30,290-c*15,5
text 60,285-c*15,c
next c
print "Thinking"
pause rand*5
print "computer play "+ p
for c = total-p+1 to total
color blue
circle 30,290-c*15,5
text 60,285-c*15,c
next c
if total<19 then goto play
if total = 19 and w=1 then
Print "I Won"
else
Print "You won"
end if
clg
font "arial",10,100
total=0 : n=1 : Sq=3
play:
input"How much add 1-3? ",a$
a=int(a$): total=total+a
if Sq<=total then
n=n+1
Sq=4*n-1
endif
if Sq-total < 4 then
p=Sq-total
w=1
else
p=int(rand*2)+1
w=0
endif
total=total+p
for c = total-a-p+1 to total-p
color red
circle 30,290-c*15,5
text 60,285-c*15,c
next c
print "Thinking"
pause rand*5
print "computer play "+ p
for c = total-p+1 to total
color blue
circle 30,290-c*15,5
text 60,285-c*15,c
next c
if total<19 then goto play
if total = 19 and w=1 then
Print "I Won"
else
Print "You won"
end if
Tuesday, October 5, 2010
Derivative
clg
Rem derivative for y= a*x^2+b*x+c
a=-1:b=-3:c=1
for y = -5 to 5 : for x = -5 to 5
circle int(30*x)+150, int(30*y)+ 150,2
next x : next y
line 150,0,150,300 : line 0,150,300,150
color red
for x = -5 to 5 step .1
y = a*x^2+b*x+c
circle 30*x +150, 150 - 30*y,2
next x
input "What is the derivative",r$
for x = -5 to 5 step .1
dy=((a*(x+.1)^2+b*(x+.1)+c)-(a*x^2+b*x+c))/.1
circle 30*x +150, 150 - 30*dy,2
next x
What is the angle?
dim arrow(8)
arrow = {0,0,0,0,0,70,0,0}
r=int(rand*2*pi)+.1
clg
fastgraphics
for i = 0 to r step .005
stamp 150,150,2,i,arrow
refresh
next i
input "What is the angle?",r$
print r*180/pi
Line equation
clg
rem generate graph
for y = -5 to 5 : for x = -5 to 5
circle int(30*x)+150, int(30*y)+ 150,3
next x : next y
line 150,0,150,300 : line 0,150,300,150
rem generate line
color red
m=int(rand*8-4)/(int(rand*4+1)): c=int(rand*8-4)
for x = -5 to 5 step .01
y = m*x+c
circle 30*x +150, 150 - 30*y,1
next x
input "What is the equation",r$
Print "y="+m+"x+"+c
Hidden dots - Sample , Averages,
clg
a=int(rand*1000)
for n = 1 to a
color rand*150,rand*150,rand*150
circle int(rand*300),int(rand*300),2
next n
pause 1
color red
for x = 0 to 9 : for y = 0 to 9
if int(rand*10)<>5 then rect x*30,y*30,30,30
next y : next x
input "How many dots are there?",r$
print a
a=int(rand*1000)
for n = 1 to a
color rand*150,rand*150,rand*150
circle int(rand*300),int(rand*300),2
next n
pause 1
color red
for x = 0 to 9 : for y = 0 to 9
if int(rand*10)<>5 then rect x*30,y*30,30,30
next y : next x
input "How many dots are there?",r$
print a
Monday, October 4, 2010
Nth term
a= int(rand*10)
b= int(rand*10)
for n = 1 to 4
print a*n + b
next n
input "What is the nth term?", x$
Print a+"n+"+b
Equation ax + b = cx +d
x= int (rand*10+2)
a= int (rand*10+2)
b= int (rand*10+2)
c= int (rand*10+2)
d=a*x+b-c*x
print a+"x+"+b+"="+c+"x"+d
input "What is x",s$
print x
Estimate the area
clg
color yellow
rect 0,0,300,300
color red
rect 0,0,20,20
color yellow
rect 0,0,300,300
color red
rect 0,0,20,20
h=int(rand*5)+1: l=int(rand*5)+1
rect 40,40,40+20*l,40+20*h
input "The small square is 1 cm^2 what is the area of the rectangle?",q$
color yellow : rect 40,40,40+20*l,40+20*h
color red
color red
a=0
for s = 0 to h+1 : for n = 0 to l+1
rect 40+20*n,40+20*s,19,19
a=a+1
print a
next n : next s
next n : next s
Guess the distance
clg
color yellow
rect 0,0,300,300
x1=rand*300
y1=rand*300
x2=rand*300
y2=rand*300
color red
circle x1,y1,4
color blue
circle x2,y2,4
Print "What is the distance between the points? "
input " " , s$
print ((x2-x1)^2 + (y2-y1)^2)^0.5
Subscribe to:
Posts (Atom)