Arduino ile 100! hesaplayan kodu chatGPT ye yazdırdım

BU chatGPT ye aklıma gelen işkence vari arduino kodları yazdırmak bir takıntı haline geldi bazen uğraştırıyor bazen ne dediğini anlamıyor bazen sabrımı taşırıyor. Daha önceleri de yaptığım denemelerde epey hatalı kodlar üretiyordu. ChatGPT ye olabildiğince net talimatla rvermek gerekiyor ve doğru sonuç verme olasılığı artmış olur.

Bugün tekrar Arduino için 100! (faktoryel) kodunu yazmasın istedim.

Chat kutusuna “write a code for arduino calculating 100! without using bigINT library”

ve chatGPT’ nin yazdığı kod;

void setup() {
  Serial.begin(9600);   // Start serial communication
}

void loop() {
  int result[200];   // Array to store the digits of the factorial
  int n = 100;   // Calculate the factorial of 100
  int length = 1;   // Current length of the factorial

  // Initialize the array with 1 digit
  result[0] = 1;

  // Multiply the factorial by each number from 2 to n
  for (int i = 2; i <= n; i++) {
    int carry = 0;   // Carry from the previous multiplication

    // Multiply each digit of the factorial by i and add the carry
    for (int j = 0; j = 0; i--) {
    Serial.print(result[i]);
  }
  Serial.println();

  while(1);   // Stop the program
}

Bu programı wowki de, siz de bu altaki linkte deneybilirsiniz

https://wokwi.com/projects/361886801962539009

Ben çalıştırdım ve sonuç

93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000

Sonucu Full Precision Calculator ‘ da teyyit ettim sonuç mükemmel.

chatGPT gitgide kendini geliştiriyor. Daha zorlu kodlara geçme zamanı geldi. Yeni denemelere devam edeceğim takipte kalın.

Advertisement

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.