Vedic Maths begins

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
smorgasbord
Posts: 493
Joined: 30 Sep 2013, 09:34

Vedic Maths begins

11 Oct 2013, 14:11

No. Square
1 1
2 4
3 9
4 16
5 25
6 36
7 49
8 64
9 81
10 100
11 121
12 144
13 169
14 196
15 225
16 256
17 289
18 324
19 361
20 400
21 441
22 484
23 529
24 576
25 625
Learn till here only the rest below follow patters like shown
26 676 ( 576+100 ) i.e. 25 -1 ....you can make out easily
27 729 ( 529+200 ) i.e. 25 -2 ....you can make out easily
28 784 ( 484+300 ) i.e. 25 -3 ....you can make out easily
29 841 ( 441+400 ) i.e. 25 -4 ....you can make out easily
30 900 ( 400+500 ) i.e. 25 -5 ....you can make out easily
31 961 ( 361+600 ) i.e. 25 -6 ....you can make out easily
32 1,024 ( 324+700 ) i.e. 25 -7 ....you can make out easily
33 1,089 ( 289+800 ) i.e. 25 -8 ....you can make out easily
34 1,156 ( 256+900 ) i.e. 25 -9 ....you can make out easily
35 1,225 ( 225+1000 ) i.e. 25 -10 ....you can make out easily
36 1,296 ( 196+1100 ) i.e. 25 -11 ....you can make out easily
37 1,369 ( 269+1200 ) i.e. 25 -12 ....you can make out easily
38 1,444 ( 144+1300 ) i.e. 25 -13 ....you can make out easily
39 1,521 ( 121+1400 ) i.e. 25 -14 ....you can make out easily
40 1,600 ( 100+1500 )
below follow still easier pattern
41 1,681 ( 15+1 . (50-41) ** 2 )
42 1,764 ( 15+2 . (50-42) ** 2 )
43 1,849 ( 15+3 . (50-43) ** 2 )
44 1,936 ( 15+4 . (50-44) ** 2 )
45 2,025 ( 15+5 . (50-45) ** 2)
46 2,116 ( 15+6 . (50-46) ** 2)
47 2,209 ( 15+7 . (50-47) ** 2)
48 2,304 ( 15+8 . (50-48) ** 2)
49 2,401 ( 15+9 . (50-49) ** 2)
50 2,500
from 50 + also you can find out the pattern.... though only till 50 are to be mugged up

in case you have mugged up squares till 50

this might help dumbfound your friends...square of some numbers could be done orally like this..

The difference in number and nearest 100s Or 1000s or 10000s (i.e. The BASE)etc should be less than 50 for the above
egs := 2991, 1002, 102, 99981, 1000021, 798, 892 etc.
Wrong eg: 2401, 3452, 198821, etc.

for correct examples bases are : 2991 (3000), 1002(1000), 102(100), 99981(100000), 1000021(1000000), 798(800), 892(900), the Base is nearest 100s, 1000s OR 10000s according to the number, we need to know the first digit of base, & no. of zeroes in it is the no. of digits in the last part of the answer ...

New number would be asked each time if it does not follow the above criteria
  • Get the last part of the answer by squaring the difference of the number and Base and then adjusting the digits so that it has as many digits as are the number of zeroes in the Base, if digits in the last part are more then add the left most part to the first part (first part calculation in second step) and trim the last part accordingly AND if the no. of digits are less than the number of zeroes in the Base then put zero(es) in the left hand side of the last part, this gives the final last part of the answer
  • To calculate the first part : if the number is more than the base then add the difference to the number , and if it is less than the base then further subtract the difference from the number, Then multiply this by the first digit of the base, then if by chance something is to be added from the last part calculation add that
  • concatenate the first part and last part, that's the anwer
edited fully

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
label:
InputBox, number, enter number

StringSplit, n, number
n := n0 - 1
c_index := 10 ** n 
c_index2 := n1 * c_index

;;;;;;;;;;;
last_part := number - C_index2
			last_part2 := last_part ** 2
		;;;;;;;;;;
	
checkpoint := mod(number, c_index2)
if ( checkpoint >= 50 )
{
 C_index2 := C_index2 + C_index
                
 last_part := C_index2 - number
 last_part2 := last_part ** 2
}
else
{
	   C_index := C_index + 10 ** n
		
}
if ( abs(number - C_index2 ) >= 50 )
	goto,  label

descriptive =  %n% places (i.e. no. of zeroes in Base)
StringSplit, fp, C_index2
StringSplit, qqqq, last_part2
number > C_index2 ? ( (middle := number + last_part . " (Q)obtained by adding " . last_part . " to " . number .  " i.e. if the number is more than base than add the difference to the number") && (initial := ( number + Last_part ) * fp1)) : ( (middle := number - last_part . " (Q)obtained by subtracting " . last_part . " from " . number .  " i.e. if the number is less than base than subtract the difference from the number") && (initial := ( number - Last_part ) * fp1))
firstpart = first part is 

if ( qqqq0 != n )
	
{	;MsgBox no. of zeroes in base %C_index2% i.e. %n% is not equal to %qqqq0% i.e. no of digits in last part i.e. %last_part2%
 if ( qqqq0 > n )
{
	initial := initial + qqqq1
	
	 totrim := qqqq0 - n
	 
;	 	MsgBox no. of digits in last part is more than digits in base by %qqqq0% - %n% and to trim is %totrim%
		StringTrimLeft, last_part3, last_part2, %totrim%

}
else 
{
{
	loop % n - qqqq0
last_part3 .= 0 
}
last_part3 := Last_part3 . last_part2
}
}
;MsgBox new initial is %initial% and last_part is %last_part3%
if ( Last_part3 = "")
	last_part3 := last_part2


MsgBox The number is %number% `n`nBase is %C_index2%(nearest 10s OR 100s or 1000s etc. to the number)`nno. of zeroes in base is %n%`n`nLast part is %last_part%(difference of number and base) square i.e. %last_part2%(LAST PART) must be in %descriptive% `nIn case it is more than %n% places add the first digit of %last_part2% i.e. %qqqq1% to the initial part`nIn case it is in lesser digits put 0(s) before it to make it that many places`n`n Result is %Last_part3% `n`n%middle%`n`nAnd the initial part is %initial% ( Obtained by multiplying first digit of base i.e. %fp1% with (Q) )`n`n Answer is initial part concatenated with Result %last_part3% i.e. %initial% . %last_part3%`n`n%initial%%last_part3%


Last edited by smorgasbord on 12 Oct 2013, 10:28, edited 13 times in total.
John ... you working ?
User avatar
smorgasbord
Posts: 493
Joined: 30 Sep 2013, 09:34

Re: Vedic Maths begins

11 Oct 2013, 14:39

Edited fully from my side.
John ... you working ?
User avatar
smorgasbord
Posts: 493
Joined: 30 Sep 2013, 09:34

Re: Vedic Maths begins

12 Oct 2013, 10:32

This message is posted to say that the main post is edited fully from my side.
hope someone actually uses it :-p
John ... you working ?
User avatar
smorgasbord
Posts: 493
Joined: 30 Sep 2013, 09:34

Re: Vedic Maths begins

13 Oct 2013, 21:52

trying to make it yet simple :-p

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
label:
InputBox, number, enter number

StringSplit, n, number
n := n0 - 1
c_index := 10 ** n 
c_index2 := n1 * c_index

;;;;;;;;;;;
last_part := number - C_index2
			last_part2 := last_part ** 2
		;;;;;;;;;;
	
checkpoint := mod(number, c_index2)
if ( checkpoint >= 50 )
{
 C_index2 := C_index2 + C_index
                
 last_part := C_index2 - number
 last_part2 := last_part ** 2
}
else
{
	   C_index := C_index + 10 ** n
		
}
if ( abs(number - C_index2 ) >= 50 )
	goto,  label

descriptive =  %n% places (i.e. no. of zeroes in Base)
StringSplit, fp, C_index2
StringSplit, qqqq, last_part2
number > C_index2 ? ( (middle := number + last_part . " (Q)obtained by adding " . last_part . " to " . number .  " i.e. if the number is more than base than add the difference to the number") && ( msg := number + Last_part . "(number + difference)" ) && ( msg2 := number + Last_part )&& (initial1 := ( number + Last_part ) * fp1)) : ( (middle := number - last_part . " (Q)obtained by subtracting " . last_part . " from " . number .  " i.e. if the number is less than base than subtract the difference from the number") && ( msg := number - Last_part . "(Number - difference)") && ( msg2 := number - Last_part )&& (initial1 := ( number - Last_part ) * fp1))
firstpart = first part is 

if ( qqqq0 != n )
	
{	;MsgBox no. of zeroes in base %C_index2% i.e. %n% is not equal to %qqqq0% i.e. no of digits in last part i.e. %last_part2%
 if ( qqqq0 > n )
{
	initial := initial1 + qqqq1
	
	 totrim := qqqq0 - n
	 
;	 	MsgBox no. of digits in last part is more than digits in base by %qqqq0% - %n% and to trim is %totrim%
		StringTrimLeft, last_part3, last_part2, %totrim%

}
else 
{
{
	loop % n - qqqq0
last_part3 .= 0 
qqqq1 := "nothing"
initial := initial1

}
last_part3 := Last_part3 . last_part2
qqqq1 := "nothing"
}
}
;MsgBox new initial is %initial% and last_part is %last_part3%
if ( Last_part3 = "")
	last_part3 := last_part2


MsgBox SQUARES TILL 50 ARE TO BE MUGGED UP FOR THIS TO WORK `n`nThe number is %number% `n`nBase is %C_index2%(nearest 10s OR 100s or 1000s etc. to the number)`nno. of zeroes in base is %n%`n`nLast part is %last_part%(difference of number and base) square i.e. %last_part2%(LAST PART) must be in %descriptive% `nIn case it is more than %n% places add the first digit of %last_part2% i.e. %qqqq1% to the initial part`nIn case it is in lesser digits put 0(s) before it to make it that many places`n`n Result is %Last_part3% `n`n%middle%`n`nAnd the initial part is %initial% ( Obtained by multiplying first digit of base i.e. %fp1% with (Q) )`n`n Answer is initial part concatenated with Result %last_part3% i.e. %initial% . %last_part3%`n`n%initial%%last_part3% `n`n **********************************OR************************************`n`nNumber = %number%, base = %C_index%, difference = %last_part%, `n`nGet(1) = %last_part2%(square of difference), Get this now(2) = %last_part3%(same number of digits as Zeroes in Base), To be added to first part in the end (***)= %qqqq1%`n`nRight hand string of the answer = %last_part3%`n`nGet %msg%, Get this %fp1% i.e. first digit of base, Multiply this %fp1% with %msg2%, get this %initial1% + %qqqq1%(***), i.e. %initial%`n`n FINAL ANSWER %initial% . %last_part3%


John ... you working ?

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 112 guests