<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recursion :: CS2 course</title><link>https://robark.gitlab.io/recursion/index.html</link><description>Chapter 7 Recursion</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Fri, 08 Jan 2021 22:21:36 +0000</lastBuildDate><atom:link href="https://robark.gitlab.io/recursion/index.xml" rel="self" type="application/rss+xml"/><item><title>Simple</title><link>https://robark.gitlab.io/recursion/simple/index.html</link><pubDate>Thu, 07 Jan 2021 19:27:34 +0000</pubDate><guid>https://robark.gitlab.io/recursion/simple/index.html</guid><description>Lesson 21: Simple Recursion Factorial:
def fact(n): if n==1: return 1 return( n*fact(n-1) ) Fibonacci:
def fib(n): if n==1 or n==0: return n return( fib(n-2) + fib(n-1) )</description></item><item><title>Fractals</title><link>https://robark.gitlab.io/recursion/fractals/index.html</link><pubDate>Fri, 08 Jan 2021 22:21:36 +0000</pubDate><guid>https://robark.gitlab.io/recursion/fractals/index.html</guid><description>Lesson 22: Recursion drawing fractals from fltk import * def mid(a,b): '''calculate midpoint of a line segment''' x=round((a[0]+b[0])/2) y=round((a[1]+b[1])/2) return (x,y) class sierpinski(Fl_Window): def __init__(self, level=7,x=100,y=0, w=700,h=700): super().__init__(x,y,w,h) self.level=level self.a=(0,h-50) #bottom left self.b=(w,h-50) #bottom right self.c=( round(w/2), round(w-((3**0.5)/2*w))-50) #top self.i=0 def draw(self): super().draw() fl_color(FL_BLUE) fl_line_style(FL_SOLID,1) self.tri(self.level, self.a, self.b, self.c) def tri(self, n, a ,b, c): if n &gt; 0: n -= 1 self.i+=1 print(self.i/2) fl_line(a[0], a[1], b[0], b[1]) fl_line(b[0], b[1], c[0], c[1]) fl_line(c[0], c[1], a[0], a[1]) ab= mid(a,b) ac= mid(a,c) bc= mid(b,c) self.tri(n, a, ab, ac) self.tri(n, b, ab, bc) self.tri(n, c, ac, bc) app=sierpinski() app.show() Fl.run() Sierpinski Triangle</description></item></channel></rss>