I'm new to computer programming. I need help with this task. I need to convert this simple C++ source code into apple dylan code. This is the original mathematical statement:
Task: Input an integer number n and output the sum: 1+22+32+...+n2. Use input validation for n to be positive.
I wrote this code in C++:
#include <iostream>
using namespace std;
int main()
{
int n;
cin >> n;
if (n < 0) return 1;
int sum = 0;
int i = 0;
while (i <= n) sum += i*i;
cout << sum;
return 0;
}
Can anyone help me to write this code into apple dylan?
Best wishes, Paul