Team 5

Number Theory Explorer

Build an app that explores number theory concepts — prime checking, GCD/LCM computation, Fibonacci generation, modular arithmetic, and prime factorization.

šŸŽÆ Learning Goals

  • ā–¹ Implement Euclidean Algorithm for GCD
  • ā–¹ Master Prime checking and factorization logic
  • ā–¹ Understand Modular Arithmetic and sequences
  • ā–¹ Build multi-panel app navigation with tabs

šŸŒŽ Why This Matters

Number theory is the foundation of digital security. Every time you buy something online with a credit card, prime numbers and modular arithmetic are being used to encrypt your transaction. It's the 'purest' math with the most critical impact.

šŸ“–Understanding Number Theory

Theory Masterclass
"

Number Theory is the branch of mathematics that studies properties and relationships of integers. Prime Number: A number greater than 1 that has no divisors other than 1 and itself. Examples: 2, 3, 5, 7, 11, 13... To check if n is prime: try dividing by all numbers from 2 to √n. If none divide evenly, it's prime. GCD (Greatest Common Divisor): The largest number that divides both numbers evenly. Euclidean Algorithm: GCD(a, b) = GCD(b, a mod b), repeat until b = 0. Example: GCD(48, 18) → GCD(18, 12) → GCD(12, 6) → GCD(6, 0) → Answer: 6 LCM (Least Common Multiple): The smallest number that both numbers divide into. LCM(a, b) = (a Ɨ b) / GCD(a, b) Fibonacci Sequence: Each number is the sum of the two before it: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34... Modular Arithmetic: The remainder when dividing. a mod n = remainder of a Ć· n. Example: 17 mod 5 = 2 (because 17 = 3Ɨ5 + 2)

Mathematical Foundation

fxPrime check: test divisibility from 2 to √n
fxGCD(a,b) = GCD(b, a mod b) — Euclidean Algorithm
fxLCM(a,b) = (a Ɨ b) / GCD(a,b)
fxFibonacci: F(n) = F(n-1) + F(n-2), F(0)=0, F(1)=1
fxModular: a mod n = a - n Ɨ floor(a/n)

šŸŽØPart A — Designer View (UI Design)

Open MIT App Inventor → Switch to Designer view. Follow each step below to build the interface.

1

1. Designer Setup

• Click **Screen1** in Components. • Set **Title** to "Number Theory Explorer". • Set **AlignHorizontal** to Center. • Set **BackgroundColor** to dark blue.

2

2. Input Area

• Drag a **Label** (User Interface). Set text to "Enter a Number:". • Drag a **TextBox**. Rename it to 'NumInput'. • Set **Width** to 'Fill Parent' and check **NumbersOnly**.

3

3. Action Buttons

• Drag a **HorizontalArrangement** (Layout). • Drag 2 **Buttons** inside. • Rename: 'PrimeBtn' (Text: "Check Prime") and 'FactorBtn' (Text: "Find Factors"). • Style them with bright green text for a "code" feel.

4

4. Result Display

• Drag a **Label** to the bottom. • Rename it to 'ResultLbl'. • Set **FontSize** to 18 and **Text** to "Analysis result will appear here".

🧩Part B — Blocks View (Logic & Calculation)

Switch to Blocks view. Now add the logic that makes your app actually work.

1

1. Switch to Blocks

• Go to the top right and click the **Blocks** button. • We will now create the math logic for checking primes.

2

2. The Prime Number Check

• Drag 'when PrimeBtn.Click' (Gold). • From **Control** (Orange), drag 'for each number from' block. • Loop from 2 to (NumInput.Text - 1). • From **Math** (Blue), drag subtraction '-' to calculate (NumInput.Text - 1). • Inside the loop, use an 'if...then' (Orange) to check if any number divides perfectly.

3

3. Using the Modulo block

• In the **Math** drawer (Blue), find the 'modulo of' block. • Modulo tells you the remainder. If remainder is 0, it means it divides evenly. • Logic: 'if [modulo of NumInput.Text by number] = 0', then 'set ResultLbl.Text to NOT PRIME'.

4

4. Getting the Factors

• Use **Text** drawer (Bright Pink) 'join' block to create a list. • Every time a number divides evenly (modulo = 0), snap it to the 'join' block. • [set ResultLbl.Text to] [join] [ResultLbl.Text] [", "] [number].

🧪Testing Your App

  • āœ“Prime: 97 is prime, 100 is not (factors: 2Ɨ2Ɨ5Ɨ5)
  • āœ“GCD(48, 18) = 6, LCM(48, 18) = 144
  • āœ“First 10 Fibonacci: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34
  • āœ“17 mod 5 = 2, 100 mod 7 = 2
  • āœ“Test with large numbers: Is 997 prime? (Yes!)

šŸš€Bonus Challenges

Extra credit — impress your instructor

  • ā˜…Add a 'Generate primes up to N' feature (Sieve of Eratosthenes)
  • ā˜…Show GCD steps visually like a flowchart
  • ā˜…Add GCD of 3 numbers: GCD(a,b,c) = GCD(GCD(a,b), c)
  • ā˜…Calculate Euler's Totient function φ(n)