# Q14 - z=check(n if(z!=0 m=z else if(n%2==1 x=(3*n 1 else...

This preview shows pages 1–2. Sign up to view the full content.

#include<iostream.h> #include<conio.h> # int count=0,a[10000][2]; i void store(int n,int m) { a[count][0]=n; a[count][1]=m; // cout<<n<<" "<<m<<endl; count++; } int check(int n) { for(int j=0;j<count;j++) { if(a[j][0]==n) return a[j][1]+1; } return 0; } int calc(int n,int m) { int z,x; if(n==1) return m;

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: z=check(n); if(z!=0) { m=z; } else { if(n%2==1) x=(3*n)+1; else x=n/2; m=calc(x,m+1); } store(n,m); return m; } void main() { clrscr(); int z=0,q,t; t=z; for(q=1;q<100;q++) { z=calc(q,1); if(z>t) { cout<<z<<" "<<q<<endl; t=z; } } getch(); } //...
View Full Document

## This note was uploaded on 10/25/2010 for the course CMPN SEM1 taught by Professor Thakur during the Spring '06 term at University of Mumbai.

### Page1 / 2

Q14 - z=check(n if(z!=0 m=z else if(n%2==1 x=(3*n 1 else...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online