ML 161: Codeium (15 pts)

What You Need

Purpose

To start using Codeium, which is free for individuals.

Note for Apple Silcon Users

When I tried to do this using MacOS on a Mac M1 in August, 2024, Codeium refused to authenticate. I succeeded by using a virtual Windows 11 machine running on the Mac M1.

Installing Python

If you are using Windows, do this project first to install Python:

VP 10: Python 3 Installed Locally

Installing Visual Studio Code

In a Web browser, go to
https://code.visualstudio.com/Download
Download and install the correct version for your operating system.

Visual Studio Code launches, as shown below.

Installing the Codeium Extension

In a Web browser, go to
https://codeium.com/
Click the green "Get Extension" button.

On the next page, you are asked to select a framework. Click "Visual Studio Code".

Create an account. I recommend signing up with Google.

A page opens titled "Codeium in Visual Studio Code".

Click the green "Quick Install" button.

In your browser, click "Start Visual Studio Code"

In Visual Studio Code, on the Codeium extension page, click the Install button, as shown below.

A series of boxes ask you to log in to various services, bouncing you back and forth between Visual Studio Code and your browser. Approve all of them.

You end up at a browser page titled "Provide Authentication Token".

Follow the instructions on that page to insert your authorization token into Visusl Studio Code.

An alternative method is to click the head icon at the lower left of Visual Studio Code and click "Sign in with Codeium...".

Creating a New File

In Visual Studio Code, on the top left, click the two-page icon.

If no folder is open, open a folder to work in.

Testing for Prime Numbers

From the menu bar, click File, "New File...".

Enter a file name of prime.py

When a box pops up in the lower right offering to install a Python extension, as shown below, click Install and perform the installation.

In the "prime.py" pane on the right side, type this line, and press Enter:
def is_prime(n):
Code appears to execute a very primitive test of primality, as shown below.

Press Tab to accept the code.

Press Enter twice to move to an empty line at the bottom.

Type this line, and press Enter:

# input integer from user
Code appears. Press Tab to accept the code.

Press Enter twice to move to an empty line at the bottom.

Type this line, and press Enter:

# test to see if num is prime
Code appears. Press Tab to accept the code, as shown below.

Running the Code

On the left side, click the icon with a triangle pointing to the right, outlined in yellow in the image below.

Click the blue "Run and Debug" button.

At the top center, click "Python debugger".

Click "Python debugger: Debug the currently active Python file".

A Python Debug Console pane opens at the lower right. At the "Enter an integer:" prompt, type

100
Press Enter.

The output says "100 is not prime", as shown below.

ML 161.1: List all Prime Factors (15 pts)

From the File menu, create a new file named list_factors.py.

Write a program that will list all the factors of a number, as shown below. This should be very easy to do.

Run the program and enter this integer:

12345
The flag is covered by a green rectangle in the image below.

Posted 8-5-24