Search found 1 match

by bafi.farid
Wed Oct 15, 2014 3:50 pm
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 320897

Re: 100 - The 3n + 1 problem

Why this code creating infinite loop?????????????
*************************
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int a,b;
int max=0,count=0;

cin>>a>>b;
if(a>b) swap(b,a);
for(int i=a;i<=b;i++)
{

while (i!=1)
{
if(i%2==0)
i=i/2;

else
i=3*i+1 ...

Go to advanced search