Initial commit

This commit is contained in:
2023-05-22 23:28:51 -03:00
commit 5c1403aa91
467 changed files with 18649 additions and 0 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,9 @@
#include <math.h>
int isPerfectSquare(int i) {
int s = sqrt(i);
return (s*s == i);
}
int isFib(int i) {
return isPerfectSquare(5*i*i+4) || isPerfectSquare(5*i*i -4);
}

View File

@ -0,0 +1,22 @@
#include <stdio.h>
int isFib (int i);
int isPrime(int i);
int main() {
int x1, x2;
printf("Please enter min value: ");
scanf("%d", &x1);
printf("Please enter max value: ");
scanf("%d", &x2);
int i;
for(i = x1; i <= x2; i++) {
if ((isFib(i) == 1) && (isPrime(i) == 1)) {
printf("%d ", i);
}
}
printf("\n");
return 0;
}

View File

@ -0,0 +1,13 @@
#include <math.h>
int isPrime(int i) {
if (i < 2) {
return 0;
}
int j, k = sqrt(i);
for(j = 2; j <= k; j++) {
if (i % j == 0) {
return 0;
}
}
return 1;
}

View File

@ -0,0 +1,15 @@
#include <stdio.h>
int isFib(int i);
int main() {
int i;
printf("Please enter a number to check if part of fibonacci sequence: ");
scanf("%d", &i);
if(isFib(i) == 1){
printf("Your number is part of the fibonacci sequence");
}
else {
printf("Your number is not part of the fibonacci sequence");
}
}

View File

@ -0,0 +1,15 @@
#include <stdio.h>
int isPrime(int i);
int main() {
int i;
printf("Please enter a number to check if prime: ");
scanf("%d", &i);
if(isPrime(i) == 1){
printf("Your number is prime");
}
else {
printf("Your number is not prime");
}
}

9
Assigments/1/isFib.c Normal file
View File

@ -0,0 +1,9 @@
#include <math.h>
int isPerfectSquare(int i) {
int s = sqrt(i);
return (s*s == i);
}
int isFib(int i) {
return isPerfectSquare(5*i*i+4) || isPerfectSquare(5*i*i -4);
}

22
Assigments/1/isFibPrime.c Normal file
View File

@ -0,0 +1,22 @@
#include <stdio.h>
int isFib (int i);
int isPrime(int i);
int main() {
int x1, x2;
printf("Please enter min value: ");
scanf("%d", &x1);
printf("Please enter max value: ");
scanf("%d", &x2);
int i;
for(i = x1; i <= x2; i++) {
if ((isFib(i) == 1) && (isPrime(i) == 1)) {
printf("%d ", i);
}
}
printf("\n");
return 0;
}

BIN
Assigments/1/isFibPrime.exe Normal file

Binary file not shown.

13
Assigments/1/isPrime.c Normal file
View File

@ -0,0 +1,13 @@
#include <math.h>
int isPrime(int i) {
if (i < 2) {
return 0;
}
int j, k = sqrt(i);
for(j = 2; j <= k; j++) {
if (i % j == 0) {
return 0;
}
}
return 1;
}

BIN
Assigments/1/testFib.exe Normal file

Binary file not shown.

BIN
Assigments/1/testPrime.exe Normal file

Binary file not shown.

15
Assigments/1/testingFib.c Normal file
View File

@ -0,0 +1,15 @@
#include <stdio.h>
int isFib(int i);
int main() {
int i;
printf("Please enter a number to check if part of fibonacci sequence: ");
scanf("%d", &i);
if(isFib(i) == 1){
printf("Your number is part of the fibonacci sequence");
}
else {
printf("Your number is not part of the fibonacci sequence");
}
}

View File

@ -0,0 +1,15 @@
#include <stdio.h>
int isPrime(int i);
int main() {
int i;
printf("Please enter a number to check if prime: ");
scanf("%d", &i);
if(isPrime(i) == 1){
printf("Your number is prime");
}
else {
printf("Your number is not prime");
}
}