Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
introduccionalafisica2023_Lopez-Jaimes
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Escuela de Fisica
Cursos
Herramientas Computacionales 23
Tareas
introduccionalafisica2023_Lopez-Jaimes
Commits
29c663cf
Commit
29c663cf
authored
2 years ago
by
Oscar Danilo Lopez Jaime
Browse files
Options
Downloads
Patches
Plain Diff
Subir nuevo archivo
parent
4afd223b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Tarea_números_primos.ipynb
+61
-0
61 additions, 0 deletions
Tarea_números_primos.ipynb
with
61 additions
and
0 deletions
Tarea_números_primos.ipynb
0 → 100644
+
61
−
0
View file @
29c663cf
{
"cells": [
{
"cell_type": "code",
"execution_count": 4,
"id": "ac852276-5e03-4b66-89f2-f742ea084b11",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149]\n"
]
}
],
"source": [
"def primo(x):\n",
" if x < 2:\n",
" return False\n",
" for y in range(2, x):\n",
" if x % y == 0:\n",
" return False\n",
" return True\n",
"\n",
"primos = [num for num in range(1, 151) if primo(num)]\n",
"\n",
"print(primos)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "943dac33-2383-4ba1-9152-a88b4eafda6b",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.9"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
%% Cell type:code id:ac852276-5e03-4b66-89f2-f742ea084b11 tags:
```
python
def
primo
(
x
):
if
x
<
2
:
return
False
for
y
in
range
(
2
,
x
):
if
x
%
y
==
0
:
return
False
return
True
primos
=
[
num
for
num
in
range
(
1
,
151
)
if
primo
(
num
)]
print
(
primos
)
```
%% Output
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149]
%% Cell type:code id:943dac33-2383-4ba1-9152-a88b4eafda6b tags:
```
python
```
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment