Skip to content
Snippets Groups Projects
Commit 922c2d2d authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

pfc-2: done

parent 74a16fa3
No related branches found
No related tags found
No related merge requests found
# pfcalcul 2
extend pfc-1 with a venv
You'll need:
- understanding of pfc-1
- a copy of this example in `/pfcalcul/work/$USER/pfc-2`
- create a venv inside and instadd dependencies, eg.:
```bash
cd /pfcalcul/work/gsaurel/pfc-2
python3 -m venv venv
source venv/bin/activate
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt
```
Then, after starting a Manager and a Boss as in pfc-1, you should be good for `sbatch ./schedule.sh`
pin
......@@ -6,4 +6,6 @@
#SBATCH --output=output-%A-%a-%N.log
#SBATCH --error=output-%A-%a-%N.err
source venv/bin/activate
HOST=pfcalcul.laas.fr ./minion.py 10
#!/usr/bin/env python3
"""Hard work here. Not efficient, but hard."""
from typing import Tuple
import pinocchio as pin # type: ignore
def is_prime(number: int) -> bool:
"""Check if a number is prime."""
return not any(number % i == 0 for i in range(2, number))
def find_prime(goal: int = 10, verbose: bool = False) -> int:
def find_prime(goal: int = 10, verbose: bool = False) -> Tuple[int, int]:
"""Find the goal-th prime number."""
found = 0
i = 1 # let's enumerate all numbers
......@@ -17,8 +21,11 @@ def find_prime(goal: int = 10, verbose: bool = False) -> int:
found += 1
if verbose:
print(f'the prime number n°{found} is {i}')
return i
n = pin.Quaternion(i, i, i, i).norm()
print(f"the norm of a quaternion with {i} as all members is {n}")
return i, n
if __name__ == '__main__':
print(find_prime(50, verbose=True))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment