Skip to content

Commit

Permalink
Merge pull request #6 from santanche/development
Browse files Browse the repository at this point in the history
feat (exercise): new exercise
  • Loading branch information
santanche authored Mar 23, 2021
2 parents 027c951 + 064cc78 commit 705183d
Showing 1 changed file with 119 additions and 0 deletions.
119 changes: 119 additions & 0 deletions notebook/pt/c51oo/s01primos/s01exercicios/primos01.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "central-briefing",
"metadata": {},
"source": [
"# Números Primos"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "senior-stack",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Este numero eh primo"
]
}
],
"source": [
"#include <stdio.h>\n",
"\n",
"int main() {\n",
" int numero = 7,\n",
" flag=0;\n",
"\n",
" for (int i = 2; i < numero; i++)\n",
" if (numero % i == 0)\n",
" flag = 1;\n",
"\n",
" if (flag == 0)\n",
" printf(\"Este numero eh primo\");\n",
" else\n",
" printf(\"Não eh primo\");\n",
"\n",
"\n",
" return 0;\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "incoming-defeat",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1\n",
"2\n",
"3\n",
"5\n",
"7\n",
"11\n",
"13\n",
"17\n",
"19\n",
"23\n"
]
}
],
"source": [
"#include <stdio.h>\n",
"\n",
"int main() {\n",
" int n = 10,\n",
" flag;\n",
"\n",
" int numero = 1;\n",
" int t = 0;\n",
" while (t < n) {\n",
" flag = 0;\n",
" for (int i = 2; i < numero; i++)\n",
" if (numero % i == 0)\n",
" flag = 1;\n",
"\n",
" if (flag == 0) {\n",
" printf(\"%d\\n\", numero);\n",
" t++;\n",
" }\n",
" \n",
" numero++;\n",
" }\n",
"\n",
" return 0;\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "accurate-hometown",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "C",
"language": "c",
"name": "c"
},
"language_info": {
"file_extension": ".c",
"mimetype": "text/plain",
"name": "c"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

0 comments on commit 705183d

Please sign in to comment.