Can anyone help with this, I'm trying it on Python. So, theres a task that says
Write a simple program that prompts the user for a certain number of cities for the Traveling Salesman problem, and displays the total number of possible routes that can be taken. Program should look like this: ''How many cities? __'' (first line) and ''For __ cities, there are __ possible routes.
I think I've done right the first part:
x = int(input("How many cities? "))
but stuck with the second one. I think about using if
, wonder if there is a way to make something like this on python: (x-1)*(x-1)
- while the second x
is the x-1
of first. Hope you get it :) Any suggestions?
If anyone will search answer, I did it!
import math
x = int(input("How many cities? "))
a = math.factorial(x)
print("For", x, "cities, there are", a, "possible routes")