Motor speed control on pico?

I have a project which involves using an environment sensor to collect PM pollution values. Based on this,a fan will turn on at different speeds according to the severity of the situation purifying the air. The problem i am facing is I cannot control the speed as is. I tried using PWM for LED’s to control speed but all the changes are audible but nothing really happens with the following code:

from machine import Pin, PWM
from time import sleep
pwm = PWM(Pin(27))
while True:
for duty in range(65025):
for duty in range(65025, 0, -1):

The alternative approach is using something from this article.
:How to Use Your Raspberry Pi Pico With DC Motors | Tom's Hardware

Is this only approach to solving this or can it be done without any additional components? I addition is it possible to achieve this buying a fan with more than 2 terminals (ie 3rd terminal for pwm).