Initial commit
This commit is contained in:
BIN
Assigments/1/Assignment One.pdf
Normal file
BIN
Assigments/1/Assignment One.pdf
Normal file
Binary file not shown.
BIN
Assigments/1/Shoebottom_Isaac_A1.docx
Normal file
BIN
Assigments/1/Shoebottom_Isaac_A1.docx
Normal file
Binary file not shown.
BIN
Assigments/1/Shoebottom_Isaac_A1.pdf
Normal file
BIN
Assigments/1/Shoebottom_Isaac_A1.pdf
Normal file
Binary file not shown.
BIN
Assigments/1/Shoebottom_Isaac_A1.zip
Normal file
BIN
Assigments/1/Shoebottom_Isaac_A1.zip
Normal file
Binary file not shown.
BIN
Assigments/1/Shoebottom_Isaac_A1/Shoebottom_Isaac_A1.pdf
Normal file
BIN
Assigments/1/Shoebottom_Isaac_A1/Shoebottom_Isaac_A1.pdf
Normal file
Binary file not shown.
9
Assigments/1/Shoebottom_Isaac_A1/isFib.c
Normal file
9
Assigments/1/Shoebottom_Isaac_A1/isFib.c
Normal 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/Shoebottom_Isaac_A1/isFibPrime.c
Normal file
22
Assigments/1/Shoebottom_Isaac_A1/isFibPrime.c
Normal 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;
|
||||
}
|
13
Assigments/1/Shoebottom_Isaac_A1/isPrime.c
Normal file
13
Assigments/1/Shoebottom_Isaac_A1/isPrime.c
Normal 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;
|
||||
}
|
15
Assigments/1/Shoebottom_Isaac_A1/testingFib.c
Normal file
15
Assigments/1/Shoebottom_Isaac_A1/testingFib.c
Normal 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");
|
||||
}
|
||||
}
|
15
Assigments/1/Shoebottom_Isaac_A1/testingPrimes.c
Normal file
15
Assigments/1/Shoebottom_Isaac_A1/testingPrimes.c
Normal 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
9
Assigments/1/isFib.c
Normal 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
22
Assigments/1/isFibPrime.c
Normal 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
BIN
Assigments/1/isFibPrime.exe
Normal file
Binary file not shown.
13
Assigments/1/isPrime.c
Normal file
13
Assigments/1/isPrime.c
Normal 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
BIN
Assigments/1/testFib.exe
Normal file
Binary file not shown.
BIN
Assigments/1/testPrime.exe
Normal file
BIN
Assigments/1/testPrime.exe
Normal file
Binary file not shown.
15
Assigments/1/testingFib.c
Normal file
15
Assigments/1/testingFib.c
Normal 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");
|
||||
}
|
||||
}
|
15
Assigments/1/testingPrimes.c
Normal file
15
Assigments/1/testingPrimes.c
Normal 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");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user