Examples

Do you want some inspiration? Check out the following examples to get a first impression on how code looks like when using smalldragon.

Example 1: Harshad Numbers


#include 

fn main () ~> int {
	
	//A Harshad Number is a number that is divisible
	//by the sum of its digits

	i = 1;
	for k in 1 .. 20 {
		
		testharshad(i);
		printf("\n");
		i = i + 1;
	}
	
	return 0;
}

fn testharshad (int n) ~> int {

	norig = n;
	sum = 0;
	
	while n != 0 {

		sum = sum + n % 10;
		n = n / 10;
	}

	bool res = norig % sum == 0;

	if res { 
		printf("%d-is-harshad", norig);
	} else {
		printf("%d-is-not-harshad", norig);
	}


	return 0;
}
	

Information:

More examples will be added in the near future.