Shreedharacharya

import 'dart:math';

//this function return a list of roots of a quadratic equation
// [x1, x2] where x1 and x2 are roots of
// aX^2 + bX + c = 0
List shreedharacharya(double a, double b, double c) {
  double d = b * b - 4 * a * c;
  List A = [];
  if (d < 0) {
    print('Imaginary roots');
  } else if (d == 0) {
    A.add(-b / (2 * a));
  } else {
    A.add((-b + sqrt(d)) / (2 * a));
    A.add((-b - sqrt(d)) / (2 * a));
  }
  return A;
}

void main() {
  double a = 1.00, b = -4.00, c = 4.00;
  List p = shreedharacharya(a, b, c);
  print(p);
}
Algerlogo

Β© Alger 2022

About us

We are a group of programmers helping each other build new things, whether it be writing complex encryption programs, or simple ciphers. Our goal is to work together to document and model beautiful, helpful and interesting algorithms using code. We are an open-source community - anyone can contribute. We check each other's work, communicate and collaborate to solve problems. We strive to be welcoming, respectful, yet make sure that our code follows the latest programming guidelines.