Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8618851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:12:09+00:00 2026-06-12T06:12:09+00:00

I decided to implement a program that can find the GCD of any two

  • 0

I decided to implement a program that can find the GCD of any two numbers (including non-integers) in TI-Basic. I’ve used this just fine in Java, so I know it works. It works just fine in TI-Basic, but when compared with the built-in gcd( function, it’s very sluggish; the gcd( function seems to get a result in milliseconds, where mine can take several seconds. Why is TI-Basic so much slower than the predefined calculator functions?

The code


Here is the program’s code in TI-Basic, for your inspection:

PROGRAM:GCD

:ClrHome
:Disp "Greatest Common","    Divisor","      ---"
:Input "First number? ",X
:Input "Second number? ",Y
:
:X→I
:Y→J
:
:If (I≠int(I) or J≠int(J))
:Then
:ClrHome
:Disp "Non-integer","inputs may be","innacurate!",""
:End
:If (I=1 or J=1)
:Then
:1→I
:1→J
:Goto Z
:End
:For(C,0,2^8)
:If I=J
:Goto Z
:
:If I>J
:I-J→I
:
:If J>I
:J-I→J
:
:End
:
:Disp "This is a hard","one! Thinking","harder..."
:
:For(C,0,2^15)
:If (I=J)
:Goto Z
:While (I>J)
:I-J→I
:C+1→C
:End
:While (J>I)
:J-I→J
:C+1→C
:End
:End
:
:Disp "TIMED OUT!","Either:",J,"or"
:Pause
:
:Lbl Z
:ClrHome
:Disp "GCD of",X,"and",Y,"is",I

Disclaimer: This is the result of me looking at my TI-84 and typing it here. Some typos might be in it, though I tried my best to keep it the same

For those of you who might not know what this means, pseudocode is provided below:

program gcd()
{
Console.clear();
Console.writeln("Greatest Common");
Console.writeln("    Divisor");
Console.writeln("      ---");

float X = Console.readFloat("First Number? ");
float Y = Console.readFloat("Second number? ");

float I = X;
float J = Y;

if (I != (int)I || J != (int)J)
{
  Console.clear();
  Console.writeln("Non-integer");
  Console.writeln("inputs may be");
  Console.writeln("inaccurate!");
  Console.writeln("");
}
if (I == 1 or J == 1)
{
  I = 1;
  J = 1;
  goto Z;
}

for(int C = 0, limit = Math.pow(2,8); C < limit; C++)
{
  if (I == J)
    goto Z;

  if (I > J)
    I = I - J;

  if (J > I)
    J = J - I;
}

Console.writeln("This is a hard");
Console.writeln("one! Thinking");
Console.writeln("harder...");

for(int C = 0, limit = Math.pow(2,15); C < limit; C++)
{
  if (I == J)
    goto z;
  while (I > J)
  {
    I = I - J;
    C++;
  }
  while (J>I)
  {
    J = J-I;
    C++;
  }
}

Console.writeln("TIMED OUT!");
Console.writeln("Either:");
Console.writeln(J);
Console.writeln("or");
Console.pause();

Z:
Console.clear();
Console.writeln("GCD of");
Console.writeln(X);
Console.writeln("and");
Console.writeln(Y);
Console.writeln("is");
Console.writeln(I);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T06:12:10+00:00Added an answer on June 12, 2026 at 6:12 am

    It’s slow because it’s an interpreted language – Disadvantages of interpreted languages.

    Basically this affects grabbing user input, as well as displaying graphics on-screen.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For a small program that I am developing, I decided it's best to implement
I'm trying implement server code of Server-Sent Events in a generic way that any
I decided to implement a very simple program recursively, to see how well Java
Currently my program allows the user to enter 5 integers which are used to
I'm trying to implement a basic worker pool using pthreads. The scenario is that
We've decided to implement CC.NET to have a readily available build for our various
I'm attempting to learn Scala so I have decided to implement datastructures with it.
I'm in the midst of a university project and have decided to implement a
Hello StackOverflow community! I started to learn Node.js recently, and decided to implement a
Having decided to try AForge for video and imaging stuff, I tried to implement

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.