2023 New Spec

From TRCCompSci - AQA Computer Science
Jump to: navigation, search

The algorithm, represented using pseudo-code, in Figure 3 outputs a series of integers. The output depends upon the value entered by the user.

Figure 3

OUTPUT "Enter an integer greater than 1: "
INPUT Number
X ← 2
Count ← 0
WHILE Number > 1
  Multi ← FALSE
  WHILE (Number MOD X) = 0
    IF NOT Multi THEN
      OUTPUT X
    ENDIF
    Count ← Count + 1
    Multi ← TRUE
    Number ← Number DIV X
  ENDWHILE
  X ← X + 1
ENDWHILE
OUTPUT Count

Table 3 lists the MOD and DIV operators for your programming language.

Table 3

Language MOD Div
C# % /

What you need to do:

Task 1

Write a program to implement the algorithm in Figure 3.

Task 2

Test that your program works:

  • run your program, then enter the number 23
  • run your program, then enter the number 25
  • run your program, then enter the number 1260