Open the Pages panel
Double-click the master page you want to edit
Select the Type tool
Draw a text frame where you want the page number to appear
Place the cursor in the text frame
Go to Type
Select Insert Special Character
Select Markers
Select Current Page Number
Format the page number text as needed
Copy the text frame to other master page locations if needed
Apply the master page to document pages
Update the master page if page numbers need to change position or style
