Programming Introduction Workshop

Here are a series of tasks for you to attempt in Sage. You will want to reference “Mini Sage Introduction” and “Programming Basics” examples in the menu.

Task 1.  Write a loop that will successively square a number modulo n.  Use it to compute $2^{1024} \pmod {101}$.  Make it show its work, by making informative print statements at each step.

 

Task 2.  Create a while loop which finds the first integer greater than 202 which is square. You can use the function is_square() to check if something is a square. It returns True or False.

 

Task 3. Create a function that finds the first integer greater than $n$ which is a square, and returns it. You will want to adapt the code you just created above.

 

Here’s a separate box for testing your function.

 

Task 4. Create a program that computes the first 100 Fibonacci numbers and places them in a list.

 

Task 5. Create a function that implements Pollard’s p-1 factorization method, on any input integer $n$. You can use Sage’s inbuilt gcd.

 

Here’s a separate box for testing your function.

 

Task 6. Implement the Sieve of Eratosthenes on the primes from 1 to 100.

 

An extra box.