#Include #Include : Int Int
#Include #Include : Int Int
//================================================================
// Bibliotecas
#include <stdio.h>
#include <stdlib.h>
// Função Principal
int n;
// Lê a posição do termo
scanf("%d", &n);
// Imprime o termo
system("pause");
return 0;
}
// Função Fibonacci
int fibonacci(int n) {
int anterior = 0,
proximo = 1,
aux,
i;
if(n == 1) {
return 0;
} else if(n == 2) {
return 1;
} else {
aux = proximo;
anterior = aux;
return proximo;
Este post foi publicado em Introdução a Algoritmos e marcado com a tag Algoritmo, Algoritmos, C,
Fibonacci, Introdução à Algoritmos, Linguagem de Programação em agosto 4, 2015.
Gerador de Números Primos – C
1 Comment
1/*
5*
7*/
8#include <stdio.h>
9#include <stdlib.h>
10
11int
12main() {
13
14int
16
17
19
20printf
21(
23);
24
25scanf
26(
27"%d"
28, &nMax);
29
35while
36(nMax < 2) {
37
38system
39(
40"cls"
41);
printf
);
scanf
"%d"
, &nMax);
for
totalDivisores = 0;
for
(j = 1; j <= i; j++) {
if
(i % j == 0) {
totalDivisores++;
if
(totalDivisores == 2) {
printf
"%4d "
, i);
printf
"n"
);
system
"pause"
);
return
0;
//================================================================
//================================================================
// Bibliotecas
#include <stdio.h>
#include <stdlib.h>
// Função Principal
int n;
// Lê a posição do termo
scanf("%d", &n);
// Imprime o termo
system("pause");
return 0;
}
// Função Fibonacci
int fibonacci(int n) {
int anterior = 0,
proximo = 1,
aux,
i;
if(n == 1) {
return 0;
} else if(n == 2) {
return 1;
} else {
aux = proximo;
anterior = aux;
return proximo;
Este post foi publicado em Introdução a Algoritmos e marcado com a tag Algoritmo,
Algoritmos, C, Fibonacci, Introdução à Algoritmos, Linguagem de Programação em agosto 4,
2015.
Gerador de Números Primos – C
1 Comment
1/*
5*
7*/
8#include <stdio.h>
9#include <stdlib.h>
10
11int
12main() {
13
14int
16
17
19
20printf
21(
23);
24
25scanf
26(
27"%d"
28, &nMax);
29
35while
36(nMax < 2) {
37
38system
39(
40"cls"
41);
printf
);
scanf
"%d"
, &nMax);
for
totalDivisores = 0;
for
(j = 1; j <= i; j++) {
if
(i % j == 0) {
totalDivisores++;
if
(totalDivisores == 2) {
printf
"%4d "
, i);
printf
"n"
);
system
"pause"
);
return
0;
//================================================================
//================================================================
// Bibliotecas
#include <stdio.h>
#include <stdlib.h>
// Função Principal
int n;
// Lê a posição do termo
scanf("%d", &n);
// Imprime o termo
system("pause");
return 0;
}
// Função Fibonacci
int fibonacci(int n) {
int anterior = 0,
proximo = 1,
aux,
i;
if(n == 1) {
return 0;
} else if(n == 2) {
return 1;
} else {
aux = proximo;
anterior = aux;
return proximo;
Este post foi publicado em Introdução a Algoritmos e marcado com a tag Algoritmo, Algoritmos, C,
Fibonacci, Introdução à Algoritmos, Linguagem de Programação em agosto 4, 2015.
Gerador de Números Primos – C
1 Comment
1/*
5*
7*/
8#include <stdio.h>
9#include <stdlib.h>
10
11int
12main() {
13
14int
16
17
19
20printf
21(
23);
24
25scanf
26(
27"%d"
28, &nMax);
29
35while
36(nMax < 2) {
37
38system
39(
40"cls"
41);
printf
);
scanf
"%d"
, &nMax);
for
totalDivisores = 0;
for
(j = 1; j <= i; j++) {
if
(i % j == 0) {
totalDivisores++;
if
(totalDivisores == 2) {
printf
"%4d "
, i);
printf
"n"
);
system
"pause"
);
return
0;