Skip to content

Instantly share code, notes, and snippets.

@kant-shashi
kant-shashi / git-status.git
Last active November 30, 2017 12:22
git-status
ShashiKant@Macbook ~/Dev/posts (master)
[64] git status -s
?? a
?? b
ShashiKant@Macbook ~/Dev/posts (master)
[66] git status -v
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
@kant-shashi
kant-shashi / prime_factorization
Created June 7, 2013 17:15
C++ code for finding the prime factorization of a given integer.
/**
* Author: Shashi Kant
* code for finding the prime factorization of a given integer.
*/
#include<iostream>
#include<cmath>
using namespace std;
int main()
@kant-shashi
kant-shashi / power
Created April 19, 2013 06:12
Finding power of a number (x ^ n) in O(log(n)) time.
//Finding power of a number (n ^ p) in O(log(n)) time.
// Author: Shashi Kant
#include<stdio.h>
long long int power(int, int);
int main()
{
int n,p;
scanf("%d %d",&n,&p);
printf("%lld\n",power(n,p));
return 0;
@kant-shashi
kant-shashi / swap
Created April 19, 2013 05:48
C Code for swapping two integers without using any other (third) variable.
/* Code for swapping two integers without using any other (third) variable.
Author: Shashi Kant
*/
#include<stdio.h>
int main()
{
int a=2,b=3;
printf("before swapping: %d %d\n",a,b);
a^=b^=a^=b;
@kant-shashi
kant-shashi / factorial
Created April 19, 2013 05:41
finding factorial of large integer like 100 is easy in python as it has inbuilt support for such large integer but c is not fortunate enough. This C code tries to give such power to the user. You can easily find factorial of very large number. I have successfully calculated factorial of an integer as large as 15000.
/* This program is for finding the factorial of a number.
Author: Shashi Kant
*/
#include<stdio.h>
int main()
{
int a[1000000];
long long unsigned int num,f,z,temp;
scanf("%lld",&num);