This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int digitsInFactorial(int N) | |
{ | |
double digits = 0; | |
if(N<=1){ return N; } | |
for(int i=2;i<=N;i++){ | |
digits += log10(i); | |
} | |
return floor(digits) + 1; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include <cmath> | |
using namespace std; | |
double findAngle(double h, double m){ | |
double angle; | |
//corner cases | |
if(h == 12) | |
h=0; | |
if(m == 60) | |
m=0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<bits/stdc++.h> | |
using namespace std; | |
typedef struct{ | |
int x, y; | |
}Point; | |
bool isSquare(Point p1, Point p2, Point p3, Point p4); | |
int dist(Point m, Point n); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<bits/stdc++.h> | |
using namespace std; | |
long long fibo(int n) | |
{ | |
long long f[n+1]; | |
f[0] = 0; f[1] = 1; | |
for(int i=2;i<=n;i++){ | |
f[i] = f[i-2] + f[i-1]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<bits/stdc++.h> | |
using namespace std; | |
#define NIL -1 | |
#define MAX 1000 | |
long long lookup[MAX]; | |
void fill() | |
{ | |
memset(lookup, NIL, MAX * sizeof(lookup[0])); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* | |
* / --------------------------------[ NUIM CS141 Java Revision ]------------------------------- \ | |
* || Designed to easily revise everything covered in CS141 by just reading through this code. || | |
* || Comments accompany almost every line of code to explain its purpose. || | |
* || Some theory we need to know are included in the bottom... || | |
* \ ------------------------------------------------------------------------------------------- / | |
* | |
* | |
* ____ _ __ ____ __ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<bits/stdc++.h> | |
#include<cmath> | |
using namespace std; | |
void SieveOfEratosthenes(int n); | |
int main(void){ | |
int n; | |
cout<<"Enter the value of n: "; | |
cin>>n; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<bits/stdc++.h> | |
#include<cmath> | |
using namespace std; | |
void SieveOfEratosthenes(int n); | |
int main(void){ | |
int n; | |
cout<<"Enter the value of n: "; | |
cin>>n; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<stdbool.h> | |
#include<math.h> | |
bool isPrime(long n); | |
int main(void){ | |
long n; | |
printf("Enter the number for primality test: "); | |
scanf("%ld", &n); | |
printf("Result: %s\n", isPrime(n)?"Is a Prime.":"Not a Prime."); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<stdbool.h> | |
bool isPrime(long n); | |
int main(void){ | |
long n; | |
printf("Enter the number for primality test: "); | |
scanf("%ld", &n); | |
printf("Result: %s\n", isPrime(n)?"Is a Prime.":"Not a Prime."); | |
} |