Month: June 2017

04
Jun
2017

Hackerearth: Seating Arrangement (Unsolved)

code that not accepted: #include<bits/stdc++.h> int main() { int i,t,rem,n,near=0,flag; scanf(“%d”,&t); for(i=0; i<t; i++) { scanf(“%d”,&n); rem=n%12…

03
Jun
2017

Algorithm: Euler’s GCD

code: int euclid_gcd(int a,int b) { int dividend,divisor,remainder; dividend = a>=b?a:b; divisor= a<=b?a:b; while(divisor!=0) { remainder=dividend%divisor; dividend=divisor;…

03
Jun
2017

Algo: Prime factorization of a number

code: #include<bits/stdc++.h> int main() { int i,n,ct=0;; scanf(“%d”,&n); for(i=2;i<=sqrt(n);i++) { if(n%i==0) { ct=0; while(n%i==0) { n=n/i; ct++;…

02
Jun
2017

Prime Number: Trial division | Prime check upto N in C

code: #include<bits/stdc++.h> int main() { int i,j,n,flag=0; printf(“enter number: “); scanf(“%d”,&n); for(i=2;i<=n;i++) //first iterate upto n {…

02
Jun
2017

Prime Finding: Sieve of Erastosthenes

I have watched the videos from mycodeschool and implemented it: code: //find all prime numbers upto n…

01
Jun
2017

HackerEarth: Prime Number

code: