Virtual Helper


Any small thing looked at a greater depth have excellent structure or pattern behind them


My parallelogram law of forces

Philosophy of Mathematics

Is Mathematics really Hard?(specially for those who hate it).I have expressed my views regarding mathematics.How Mathematics is associated with all walks of human life.

learn more

Web technology

Everything in the world is connected.This is another nice article related to div tag.

learn more

Another webtechnology post

Funny illustration of webtechnology related concept.How web technology various branches associated with the human life

learn more

Free Educational Video

Treasure Resources

All open resources Educational resources under one shell for all subjects .Don't forgot to bookmark this.

learn more

Josephus Flavius problem for everywhich 2



Josephus Flavius was a famous Jewish historian of the first century at the time of the Second Temple destruction. During the Jewish-Roman war he got trapped in a cave with a group of n soldiers surrounded by romans. The legend has it that preferring suicide to capture, the Jews decided to form a circle and, proceeding around it, to kill every second remaining person until no one was left. Josephus, not keen to die, quickly found the safe spot in the circle and thus stayed alive.
#include<stdio.h>
void main()
{
int a=1,n,j=1,i;
clrscr();
printf("\n Enter the number \n");
scanf("%d",&n);
while(a<n)
{
a=a*2;
printf("\n%d ",a);
}
if(a==n)
{
printf("\n The number entered is a power of 2");
printf("\n the answer is 1");
}
else
{
a=a/2;
n=n-a;
for(i=1;i<=n;i++)
{
j+=2;
}
printf("\n the answer is %d",j);
}
getch();
}


Responses

0 Respones to "Josephus Flavius problem for everywhich 2"

Post a Comment

 
Return to top of page Copyright © 2010 | Platinum Theme Converted into Blogger Template by HackTutors