Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Fibonacci Spiral
- // By Temi Taylor
- // When running main, n is how many numbers of the sequence it goes through
- public class Lies
- {
- private static void fibs(Turtle t, int n)
- {
- int[] x = new int[n];
- x[0] = 1;
- x[1] = 1;
- for (int i = 0; i < n; i ++)
- {
- if (i > 1)
- {
- x[i] = x[i-1] + x[i-2];
- }
- quart(t, x[i]);
- System.out.println(x[i]);
- }
- }
- static void quart(Turtle t, double r)
- {
- for (int i = 0; i < 10; i += 1)
- {
- t.forward(3.14159265 * 0.5 * r);
- t.left(9);
- }
- }
- public static void main(int n)
- {
- Turtle t = new Turtle();
- t.up();
- t.setPosition(0, 0);
- t.down();
- t.speed(5);
- fibs(t, n);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement