0

Command prompt

I tried to run this python code:

#two brown number are an ordered pair in the form (m; n) such that n!+1=m^2
from math import factorial as fact
m=2
n=2
for i in range(10**2): # range of values to check
    # checks current values and changes them according to results
    if (fact(n)+1)==m**2:
        print(m,n)
        m+=1
        n+=1
    elif (fact(n)+1)<m**2:
        n+=1
    elif (fact(n)+1)>m**2:
        m+=1

from the command prompt but it showed me the message on the image above, even though I already installed python 3.9 from the official website.

The python stuff I installed

Anyone knows how to fix this or do I have to reinstall python from the Microsoft Store?

5
  • 1
    The image is not visible Commented Aug 26, 2021 at 10:57
  • Please do not upload images of code/errors when asking a question. Edit your question to include the relevant information as text. Commented Aug 26, 2021 at 11:00
  • 1
    You should use the full python installation path or try with py program.py Commented Aug 26, 2021 at 11:01
  • why are you running python brown scriptname.py try using python scriptname.py, just scriptname.py or py scriptname.py Commented Aug 26, 2021 at 11:03
  • If you installed cpython did you tick the PATH box. It's also unticked in the image ... docs.python.org/3/using/windows.html Commented Aug 26, 2021 at 11:03

2 Answers 2

1

Rename your file containing the code. There must not be spaces and then use the command:

python3 filename.py

Sign up to request clarification or add additional context in comments.

Comments

1

To call files with spaces use the quotation marks around them. python ".\brown numbers.py"

Generally, it is better to avoid spaces in files names, but sometimes it is unavoidable. In such situations you must explicitly tell Python what is the full file name.

To check if Python is installed correctly run: python --version

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.