Rechenkurs GAP (Wintersemester 2014/2015)

News

2015-10-09
Update for sheet 2: explain how "for"-loops in GAP work in more detail
2015-09-14
Some cosmetic revisions
2014-11-06
Add the "bad locals" example
2014-11-05
Uploaded slightly revised versions of worksheets 3 and 4

Worksheets

Bonus problems

Bonus problems are good for a bonus homework point each.

Sieve (deadline 20. November 2014)

Write a function Sieve(n) which takes a positive integer n, and returns a list containing all primes less or equal n, in strictly ascending order. Compute this list using the sieve of Eratosthenes. Submit your solution in a file called sieve.g.

Your program should be able to compute Sieve(10^7) in under 20 seconds.

Hint: You can use the function RootInt to compute an integer approximation of the square root of an integer (consult the manual to learn how to use it). However, it is also fine to write a solution working without it.

Hint: The function Add may also be useful: It can append a single element to the end of a list (again, please consult the GAP manual for details).

Miscellaneous

The perils of not using local properly

You can find the "bad" example from today's class here.
Autor: Max Horn